I am currently looking into the WinHttp API and have come across the WinHttpConnect()
function which is described here. The parameter description is quite worrying for me. The aforementioned page first gives the function prototype as
WINHTTPAPI HINTERNET WinHttpConnect(
[in] HINTERNET hSession,
[in] LPCWSTR pswzServerName,
[in] INTERNET_PORT nServerPort,
[in] DWORD dwReserved
);
and continues with the parameter description. The second input parameter is explained as follows (leaving away the last two irrelevant sentences):
[in] pswzServerName
Pointer to a null-terminated string that contains the host name of an HTTP server. Alternately, the string can contain the IP address of the site in ASCII, for example, 10.0.1.45. […]
That’s the part I am struggling with. In C, a string consists either of wide characters (as the parameter type LPCWSTR
implies) or of bytes (as the wording “IP address […] in ASCII” implies). It is not clear to me how the function can distinguish whether the bytes at the memory location the parameter points to are bytes making up a narrow string or are wide characters making up a wide string.
Can somebody shed some light on this?