void CrackUrl()
{
URL_COMPONENTS uc;
char Scheme[1000];
char HostName[1000];
char UserName[1000];
char Password[1000];
char UrlPath[1000];
char ExtraInfo[1000];
uc.dwStructSize = sizeof(uc);
uc.lpszScheme = Scheme;
uc.lpszHostName = HostName;
uc.lpszUserName = UserName;
uc.lpszPassword = Password;
uc.lpszUrlPath = UrlPath;
uc.lpszExtraInfo = ExtraInfo;
uc.dwSchemeLength = 1000;
uc.dwHostNameLength = 1000;
uc.dwUserNameLength = 1000;
uc.dwPasswordLength = 1000;
uc.dwUrlPathLength = 1000;
uc.dwExtraInfoLength = 1000;
InternetCrackUrl(
"http://hoge:henyo@www.cool.ne.jp:8080/masapico/api_sample.index",
0, 0, &uc);
printf("scheme: '%s'\n", uc.lpszScheme);
printf("host name: '%s'\n", uc.lpszHostName);
printf("port: %d\n", uc.nPort);
printf("user name: '%s'\n", uc.lpszUserName);
printf("password: '%s'\n", uc.lpszPassword);
printf("url path: '%s'\n", uc.lpszUrlPath);
printf("extra info: '%s'\n", uc.lpszExtraInfo);
printf("scheme type: ");
switch(uc.nScheme) {
case INTERNET_SCHEME_PARTIAL: printf("partial.\n"); break;
case INTERNET_SCHEME_UNKNOWN: printf("unknown.\n"); break;
case INTERNET_SCHEME_DEFAULT: printf("default.\n"); break;
case INTERNET_SCHEME_FTP: printf("FTP.\n"); break;
case INTERNET_SCHEME_GOPHER: printf("GOPHER.\n"); break;
case INTERNET_SCHEME_HTTP: printf("HTTP.\n"); break;
case INTERNET_SCHEME_HTTPS: printf("HTTPS.\n"); break;
case INTERNET_SCHEME_FILE: printf("FILE.\n"); break;
case INTERNET_SCHEME_NEWS: printf("NEWS.\n"); break;
case INTERNET_SCHEME_MAILTO: printf("MAILTO.\n"); break;
default: printf("%d\n", uc.nScheme);
}
}
BOOL InternetCrackUrl(
IN LPCSTR Url,
IN DWORD UrlSize,
IN DWORD Flags,
IN OUT LPURL_COMPONENTS UrlComponents);