一.Url相关函数
1.InternetCreateUrl
Cracks a URL into its component parts.
#define URL_STRING_TEST "http://www.cnblogs.com/Clingingboy/archive/2011/11/20/2256200.html"void main(){ TCHAR szHostName[128]; TCHAR szUrlPath[256]; URL_COMPONENTS crackedURL; ZeroMemory(&crackedURL, sizeof (URL_COMPONENTS)); crackedURL.dwStructSize = sizeof (URL_COMPONENTS); crackedURL.lpszHostName = szHostName; crackedURL.dwHostNameLength = sizeof(szHostName); crackedURL.lpszUrlPath = szUrlPath; crackedURL.dwUrlPathLength = sizeof(szUrlPath); InternetCrackUrl(URL_STRING_TEST,(DWORD)strlen(URL_STRING_TEST),0,&crackedURL);}
2.InternetCreateUrl
Creates a URL from its component parts.
DWORD urlLength;InternetCreateUrl(&crackedURL,ICU_ESCAPE,szUrlPath,&urlLength);
3.InternetCanonicalizeUrl
Canonicalizes a URL, which includes converting unsafe characters and spaces into escape sequences.
InternetCanonicalizeUrl("http://www.xxx.com/viewthread.php?action=printable&tid=99 ",szUrlPath,&urlLength,ICU_ENCODE_SPACES_ONLY);
4.InternetCombineUrl
Combines a base and relative URL into a single URL.
InternetCombineUrl("http://www.xxx.com/","2256200.html",szUrlPath,&urlLength,ICU_BROWSER_MODE);
二.Internet基本应用相关函数
1.InternetOpen
Initializes an application's use of the WinINet functions.
2.InternetOpenUrl
Opens a resource specified by a complete FTP, Gopher, or HTTP URL.
3.InternetReadFile
Reads data from a handle opened by the InternetOpenUrl, FtpOpenFile, GopherOpenFile, or HttpOpenRequest function
4.InternetCloseHandle
Closes a single Internet handle.
应用1:打开因特网上指定的文件
void Download(){ DWORD byteread=0; char buffer[100]; memset(buffer,0,100); HINTERNET internetopen; internetopen=InternetOpen("Testing",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0); if (internetopen==NULL) { cout<<"Internet open failed!"<
三.连接检查函数
1.InternetCheckConnection
Allows an application to check if a connection to the Internet can be established.
BOOL result=InternetCheckConnection(URL_STRING_TEST,FLAG_ICC_FORCE_CONNECTION,0);
2.InternetAttemptConnect
Attempts to make a connection to the Internet.
BOOL result=InternetAttemptConnect(0);