我正在尝试使用 internetcheckconnection() 检查用户的互联网连接 .
代码:
#include
#include
#include
#include
#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,但仍然会出现这些错误 . 如果你能解决这个简单的问题,那会很好 . :)