InternetCheckConnection always returns false

I want to use the function Wininet InternetCheckConnectionto check when the machine is connected to the Internet and can access a specific host. The problem is that this function always returns false , no matter what URL I put on it.

MSDN Link

+3
source share
3 answers

The following combination works for me on Windows 7 and Windows XP SP3:

 InternetCheckConnection("http://www.google.com", FLAG_ICC_FORCE_CONNECTION, 0) ;

GetLastError () returns 0 if communication is possible and returns 12029 (an attempt to connect to the server failed), if not.

The following combinations do not work for me:

  InternetCheckConnection(NULL, FLAG_ICC_FORCE_CONNECTION, 0) ;

GetLastError () returns 12016 (the requested operation is not valid).

  InternetCheckConnection(NULL, 0, 0) ;
  InternetCheckConnection(("http://www.google.com", 0, 0) ;

GetLastError() 2250 ( ).

+5

GetLastError()? MSDN, ERROR_NOT_CONNECTED, , .

+3

, , , , DLL Windows / ?

0

Source: https://habr.com/ru/post/1703423/


All Articles