我想等到互联网来了,所以我用 InternetGetConnectedState 函数创建了一个循环。我在禁用互联网时启动了程序。然后我启用了互联网。但它仍然不存在。我该怎么办?
LPWORD bur;
int abc;
abc = InternetGetConnectedState(bur,0);
while (abc==0){
printf ("zzz");
if (abc==1)
break;
}
尝试将调用置于循环中,abc 永远不会改变。
此外,您不应该将结果分配给 abc ....而且,它是一个 DWORD ...
DWORD abc = 0;
printf ("Waiting for an internet connection.");
while ((abc & 0x40)){
InternetGetConnectedState(&abc,0);
printf (".");
}
然后将其与 1 或 0 进行比较并不能真正告诉您任何信息,请查看它可以返回的标志:-
INTERNET_CONNECTION_CONFIGURED
0x40
Local system has a valid connection to the Internet, but it might or might not be currently connected.
INTERNET_CONNECTION_LAN
0x02
Local system uses a local area network to connect to the Internet.
INTERNET_CONNECTION_MODEM
0x01
Local system uses a modem to connect to the Internet.
INTERNET_CONNECTION_MODEM_BUSY
0x08
No longer used.
INTERNET_CONNECTION_OFFLINE
0x20
Local system is in offline mode.
INTERNET_CONNECTION_PROXY
0x04
Local system uses a proxy server to connect to the Internet.
INTERNET_RAS_INSTALLED
0x10
Local system has RAS instal