hsession=::InternetOpen("IE",INTERNET_OPEN_TYPE_DIRECT,NULL,INTERNET_INVALID_PORT_NUMBER,0);
if(hsession==NULL)
{
return FALSE;
}
// 连接到http://www.baidu.com/
hconnect=::InternetConnect(hsession,"www.baidu.com",INTERNET_INVALID_PORT_NUMBER,"","",INTERNET_SERVICE_HTTP,0,0);
if(hconnect==NULL)
{
return FALSE;
}
//hhttpfile=::HttpOpenRequest(hconnect,"GET","/MSDN/MSDNINFO/",HTTP_VERSION,NULL,0,INTERNET_FLAG_FROM_CACHE,0);
hhttpfile=::HttpOpenRequest(hconnect,"GET","HTTP/1.1",HTTP_VERSION,NULL,0,INTERNET_FLAG_FROM_CACHE,0);
if(hhttpfile==NULL)
{
return FALSE;
} BOOL bsendRequest=::HttpSendRequest(hhttpfile,NULL,0,NULL,0);
if(bsendRequest==TRUE)
{
MessageBox("ok-4");//???
}
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384247(v=vs.85).aspx
Return value
Returns TRUE if successful, or FALSE otherwise. To get extended error information, call GetLastError.WinINet Constants
http://msdn.microsoft.com/en-us/library/windows/desktop/aa385448(v=vs.85).aspx
Error Messages 错误标识说明(GetLastError)
http://msdn.microsoft.com/en-us/library/windows/desktop/aa385465(v=vs.85).aspx
HTTP Status Codes HTTP状态码
http://msdn.microsoft.com/en-us/library/windows/desktop/aa384325(v=vs.85).aspx
这样请求有问题?请具体帮我指出一下,谢谢
int m_BodyLen = static_cast <DWORD> (strlen(pLoginBody));BOOL hSendRequest = HttpSendRequest(hRequest, m_Header.c_str(),m_Header.length(), (LPVOID)(pLoginBody), m_BodyLen );if(!hSendRequest)
return false;InternetCloseHandle(hRequest);
InternetCloseHandle(hConnect);
InternetCloseHandle(hOpen);