[英]checking internet connection in c++ using internetcheckconnection
我試圖通過使用internetcheckconnection()
來檢查用戶的互聯網連接。
編碼:
#include <Wininet.h>
#include <iostream>
#include <string.h>
#include <windows.h>
#pragma comment(lib, "wininet.lib")
int main()
{
char url[128];
strcat(url, "http://www.techtoolbox.com");
bool bConnect = InternetCheckConnection(url, FLAG_ICC_FORCE_CONNECTION, 0);
if (bConnect) {
//internet connection exists !
std::cout << "yes";
}
else {
std::cout << "no ";
}
return 0;
}
但是很多錯誤都會出現
29 11 C:\\ Program Files(x86)\\ Dev-Cpp \\ MinGW64 \\ x86_64-w64-mingw32 \\ include \\ Wininet.h [錯誤]'LPVOID'未命名類型
30 11 C:\\ Program Files(x86)\\ Dev-Cpp \\ MinGW64 \\ x86_64-w64-mingw32 \\ include \\ Wininet.h [錯誤]'HINTERNET'沒有命名類型
32 11 C:\\ Program Files(x86)\\ Dev-Cpp \\ MinGW64 \\ x86_64-w64-mingw32 \\ include \\ Wininet.h [錯誤]'WORD'沒有命名類型,還有431個。
我已經安裝了Wininet.lib,但仍然會出現這些錯誤。 如果你能解決這個簡單的問題,那會很好。:)
您的錯誤消息中的LPVOID
, HINTERNET
和其他類型在windows.h
中聲明。 您應該重新安排包含以修復這些錯誤:
#include <windows.h>
#include <Wininet.h>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.