InternetGetConnectedState() with WinInet.h

i searched a lot before posting here.
i cant use this to determine if user has working internet connection or not.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <windows.h>
#include <WinInet.h> // or wininet.h or WININET.h same error

//#pragma comment(lib, "wininet") // with or without this line same error remains.

int main(int argc, char** argv)
     {

        BOOL result;

	DWORD dwReturnedFlag;
	if( InternetGetConnectedState(&dwReturnedFlag, 0) ) 
         //or 
        //InternetGetConnectedState("http://www.google.com", FLAG_ICC_FORCE_CONNECTION, 0);

	{
	result = TRUE;
	}
	else
	{
	result = FALSE;
	}
	std::cout << result;
	Sleep(2000);
	return 0;
}


the error is here http://imgur.com/MfYCCy2

sorry for being a newbie .
Last edited on
here is another way if (system("ping www.google.com
but my ISP blocks ping . ping wouldn't work
Last edited on
Topic archived. No new replies allowed.