这里 SendPost() 将向服务器发送 HTTP GET 请求。当我用来编译此代码片段时,它显示“错误 C2275:'HINTERNET':非法使用这种类型作为表达式”。我在程序的开头包含了“wininet.h”,即使它显示错误。
void SendPost(TCHAR *szName, TCHAR *szNumber, YACINFO *yi)
{
TCHAR szText[128], szLogText[256], szFormat[256];
GetDateTimeString(szText, 128);
LoadString(yi->hinst, IDS_INCOMING_CALL_HEADER, szFormat, 256);
_snprintf(szLogText, 256, szFormat, szText);
LoadString(yi->hinst, IDS_LOGFILE_NAME, szFormat, 256);
_snprintf(szLogText, 256, szFormat, szName);
LoadString(yi->hinst, IDS_LOGFILE_NUMBER, szFormat, 256);
_snprintf(szLogText, 256, szFormat, szNumber);
MessageBox(NULL,szNumber,"Status",MB_OK);
HINTERNET hSession = InternetOpen("Utility", 0,NULL, NULL, 0);
HINTERNET hOpenUrl = InternetOpenUrl(hSession,"http://www.ourwebsite.com/index.php?sender=123&&receiver=124&&msgdata=sample SMS today&&recvtime=01:12&&msgid=123458", NULL,0, 1, 1);
if( hOpenUrl == NULL){
//invalid URL
}
InternetCloseHandle(hOpener);
InternetCloseHandle(hSession);
MessageBox(NULL,"Request Send","Status",MB_OK);
}