vc 获取网页内容(HTTP)
睿丰德科技 专注RFID识别技术和条码识别技术与管理软件的集成项目。质量追溯系统、MES系统、金蝶与条码系统对接、用友与条码系统对接
BOOL bResult = FALSE;
// 初始化WinInet 环境
HINTERNET hInternet = InternetOpen("CEHTTP", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, NULL);
if(hInternet == NULL)
return ;
// 打开http session
HINTERNET hSession = InternetConnect(hInternet, "www.hao123.com", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
if(hSession == NULL)
return ;
// 打开http post 请求的句柄
char* szAccept[] = {"*/*", NULL};
HINTERNET hRequest = HttpOpenRequest(hSession, "GET", NULL,
NULL, NULL, (LPCSTR*)szAccept, INTERNET_FLAG_NO_CACHE_WRITE, 0);
if (hRequest == NULL)
return ;
// 外发的header
char headerLanguage[] = "Accept-Language: zh-cn/r/n";
char headerEncoding[] = "Accept-Encoding: gzip, deflate/r/n";
char headerContentType[] = "Content-Type: text/xml/r/n";
// 添加header 信息
// bResult = HttpAddRequestHeaders(hRequest, headerLanguage, -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE);
// bResult = HttpAddRequestHeaders(hRequest, headerEncoding, -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE);
// bResult = HttpAddRequestHeaders(hRequest, headerContentType, -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE);
//
if(!HttpSendRequest(hRequest,NULL,0,NULL,0))
return ;
TCHAR szBuf[256];
DWORD dwRet = -1;
while (InternetReadFile(hRequest,szBuf,256,&dwRet) && dwRet!= 0)
{
OutputDebugString(szBuf);
}RFID管理系统集成商 RFID中间件 条码系统中间层 物联网软件集成
// 初始化WinInet 环境
HINTERNET hInternet = InternetOpen("CEHTTP", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, NULL);
if(hInternet == NULL)
return ;
// 打开http session
HINTERNET hSession = InternetConnect(hInternet, "www.hao123.com", 80, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
if(hSession == NULL)
return ;
// 打开http post 请求的句柄
char* szAccept[] = {"*/*", NULL};
HINTERNET hRequest = HttpOpenRequest(hSession, "GET", NULL,
NULL, NULL, (LPCSTR*)szAccept, INTERNET_FLAG_NO_CACHE_WRITE, 0);
if (hRequest == NULL)
return ;
// 外发的header
char headerLanguage[] = "Accept-Language: zh-cn/r/n";
char headerEncoding[] = "Accept-Encoding: gzip, deflate/r/n";
char headerContentType[] = "Content-Type: text/xml/r/n";
// 添加header 信息
// bResult = HttpAddRequestHeaders(hRequest, headerLanguage, -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE);
// bResult = HttpAddRequestHeaders(hRequest, headerEncoding, -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE);
// bResult = HttpAddRequestHeaders(hRequest, headerContentType, -1, HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE);
//
if(!HttpSendRequest(hRequest,NULL,0,NULL,0))
return ;
TCHAR szBuf[256];
DWORD dwRet = -1;
while (InternetReadFile(hRequest,szBuf,256,&dwRet) && dwRet!= 0)
{
OutputDebugString(szBuf);
}RFID管理系统集成商 RFID中间件 条码系统中间层 物联网软件集成