what am i doing wrong ? :)

if(InternetGetConnectedState(INTERNET_CONNECTION_LANINTERNET_CONNECTION_MODEM , 0) == true)
			{
		cout << "internet alive";
			}
error: invalid conversion from `int' to `DWORD*'
 error:   initializing argument 1 of `BOOL InternetGetConnectedState(DWORD*, DWORD)'

Recommended Answers

All 4 Replies

sorry,its:

if(InternetGetConnectedState(INTERNET_CONNECTION_LAN | INTERNET_CONNECTION_MODEM , 0) == true)

If you want you can try this:

//Check InternetConnection:
			 HttpWebRequest^ req;
			 HttpWebResponse^ resp;

				req = (HttpWebRequest^)WebRequest::Create("http://www.google.com");
				resp = (HttpWebResponse^)req->GetResponse();

				if(resp->StatusCode == HttpStatusCode::OK )
				{
					//It is Connected
				}
					else
					{
							 MessageBox:: Show("Internet Connection was Not Found \nCheck Connection.", "Internet Connection", MessageBoxButtons::OK, MessageBoxIcon::Information);
							 break;
					}
				}
commented: Which libary i should use for this code +0

Luke you are assuming the use of VC++, it might be unmanaged C++ he is using.

Rather than passing what type of connection you wish to check, you should be passing a pointer to a data structure to hold the different connections that are avaliable to you.

So you should be passing a LPDWORD* to grab the data. Then check the content of the returned data structure.


Chris

See the documentation on InternetGetConnectedState()

The first parameter is a pointer to a DWORD (i.e. LPDWORD), which receives one or more of the flags, as described.

So, rather use ..

DWORD dwFlags;
BOOL bState = InternetGetConnectedState(&dwFlags, 0);
// .. check the state + the flags

It seems to be a quite tricky function wrt. correct interpretation of the received state/flags, so good luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.