如何让程序识别连接一个网站页面出错,自动返回错误信息。
CHttpFile::QueryInfoStatusCode
This method returns the status code associated with an HTTP request and places it in the supplied dwStatusCode parameter. Use this method only after a successful call to SendRequest or on a CHttpFile object successfully created by OpenURL.
BOOL QueryInfoStatusCode(
DWORD& dwStatusCode )
const;
Parameters
dwStatusCode
Specifies a reference to a status code. Status codes indicate the success or failure of the requested event. See the Remarks section for a selection of status code descriptions.
Return Value
Nonzero if it is successful; otherwise, it is zero. If the call fails, the Window CE function GetLastError may be called to determine the cause of the error.
Remarks
Call this method to get the status code associated with an HTTP request and place it in the supplied dwStatusCode parameter. Use this method only after a successful call to SendRequest or on a CHttpFile object successfully created by OpenURL.
HTTP status codes fall into groups indicating the success or failure of the request. The following tables outline the status code groups and the most common HTTP status codes.
Group Meaning
200-299 Success
300-399 Information
400-499 Request error
500-599 Server error
如果用SDK可用HttpQueryInfo
This example demonstrates a call to HttpQueryInfo.
bRet = HttpQueryInfo(hResource, HTTP_QUERY_RAW_HEADERS_CRLF,
lpvSomeBuffer, &dwSize, NULL);