C ++获得LPCWSTR和LPVOID的长度

For*_*vin 1 c++ string-length lpcwstr

Winapi函数WinHttpSendRequest()希望第三个参数中的第二个参数的大小和第五个参数中第四个参数的大小。
我该如何计算?
我有一个包装在它周围的函数,我直接传递字符串,大概是这样的:

void Req(LPCWSTR headers, LPVOID body) {
    WinHttpSendRequest( hRequest, headers, (DWORD)strlen(headers), body, (DWORD)strlen(body), 0, 0 );
}
Req(L"User-Agent: blabla/1.0\r\nConnection: Keep Alive", "asdf=qwer&abcd=1234);
Run Code Online (Sandbox Code Playgroud)

上面的代码不起作用。:/
希望您能帮帮我。

oog*_*oga 5

您需要使用wcslen而不是strlen宽字符串。