Windows网络编程API整理
Windows网络编程API整理
头文件:winhttp.h
-
URL解析成host和port
参考链接:https://docs.microsoft.com/en-us/windows/win32/api/winhttp/nf-winhttp-winhttpcrackurl
给定一个宽字符的pwszUrl地址,解析成lpUrlComponentsINHTTPAPI BOOL WinHttpCrackUrl( [in] LPCWSTR pwszUrl, [in] DWORD dwUrlLength, [in] DWORD dwFlags, [in, out] LPURL_COMPONENTS lpUrlComponents );
LPURL_COMPONENTS结构:
typedef struct { DWORD dwStructSize; // size of this structure. Used in version check LPWSTR lpszScheme; // pointer to scheme name DWORD dwSchemeLength; // length of scheme name INTERNET_SCHEME nScheme; // enumerated scheme type (if known) LPWSTR lpszHostName; // pointer to host name(获取主机名) DWORD dwHostNameLength; // length of host name INTERNET_PORT nPort; // converted