How to find if a machine is having internet connection.
-
Hi I am writing an application which needs to know if the user is having internet connection enabled or not. I want this checking to be done automatically by the application, I donot want to pop up connect internet dialog. Can anyone tell me if there is any API/function to findout that the machine is having internet connection. Regards, Ruchirdhar Dwivedi RuchirDhar Dwivedi Software Engineer Windowmaker Software Pvt.Ltd. Baroda, India.
mr ruchir use his api
InternetGetConnectedState
This function retrieves the connected state of the local system.
BOOL InternetGetConnectedState(
LPDWORD lpdwFlags,
DWORD dwReserved);
"I Think this Will Help"
visit me at http://www.thisisalok.tk
-
mr ruchir use his api
InternetGetConnectedState
This function retrieves the connected state of the local system.
BOOL InternetGetConnectedState(
LPDWORD lpdwFlags,
DWORD dwReserved);
"I Think this Will Help"
visit me at http://www.thisisalok.tk
InternetGetConnectedState()
only works for modem connections. It will returnFALSE
even if the user is connected via a network. The only truly correct method of knowing is by actually trying to connect to a known website. If it works, then you're connected. If it doesn't work, then you're probably not connected (not definitely - the website might be down).Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
InternetGetConnectedState()
only works for modem connections. It will returnFALSE
even if the user is connected via a network. The only truly correct method of knowing is by actually trying to connect to a known website. If it works, then you're connected. If it doesn't work, then you're probably not connected (not definitely - the website might be down).Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
small question Sir!, then what is meaning of INTERNET_CONNECTION_LAN in above api thanks
"I Think this Will Help"
visit me at http://www.thisisalok.tk
-
InternetGetConnectedState()
only works for modem connections. It will returnFALSE
even if the user is connected via a network. The only truly correct method of knowing is by actually trying to connect to a known website. If it works, then you're connected. If it doesn't work, then you're probably not connected (not definitely - the website might be down).Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
Hey I was just searching on the MSDN and I got something WinInet API's in which there is function InternetOpen(...) will it help me?? I mean just checking handle (if null then no internet, if not null internet available.) Do anyone has any idea about this WinInet API and tell me whether it will help me?? Regards. RuchirDhar Dwivedi. RuchirDhar Dwivedi Software Engineer Windowmaker Software Pvt.Ltd. Baroda, India.
-
Hey I was just searching on the MSDN and I got something WinInet API's in which there is function InternetOpen(...) will it help me?? I mean just checking handle (if null then no internet, if not null internet available.) Do anyone has any idea about this WinInet API and tell me whether it will help me?? Regards. RuchirDhar Dwivedi. RuchirDhar Dwivedi Software Engineer Windowmaker Software Pvt.Ltd. Baroda, India.
RuchirD wrote: function InternetOpen(...) will it help me?? i don't think soo,as msdn state that "This function initializes an application’s use of the
Windows CE
Internet functions." the equivalent function for windows isInternetOpenUrl().
"I Think this Will Help"
visit me at http://www.thisisalok.tk
-
RuchirD wrote: function InternetOpen(...) will it help me?? i don't think soo,as msdn state that "This function initializes an application’s use of the
Windows CE
Internet functions." the equivalent function for windows isInternetOpenUrl().
"I Think this Will Help"
visit me at http://www.thisisalok.tk
This function initializes an application’s use of the Windows CE Internet functions." I think there is some confusion. Windows function call InternetOpenURL uses Handle that is returned by the function call InternetOprn(...) Pls see below InternetOpenUrl Opens a resource specified by a complete FTP, Gopher, or HTTP URL. HINTERNET InternetOpenUrl( HINTERNET hInternet, LPCTSTR lpszUrl, LPCTSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD_PTR dwContext ); Parameters hInternet [in] Handle to the current Internet session. The handle must have been returned by a previous call to InternetOpen Plz correct me if I am wrong. What I could conclude from the MSDN excerpt is that "InternetOpen returns handle to the internet session if connected and if not it will return null, using this handle we can open an URL using InternetOpenURL() function". Also the exact use case is "check if user is connected to the internet". Thanks n Regards RuchirDhar Dwivedi. RuchirDhar Dwivedi Software Engineer Windowmaker Software Pvt.Ltd. Baroda, India.
-
This function initializes an application’s use of the Windows CE Internet functions." I think there is some confusion. Windows function call InternetOpenURL uses Handle that is returned by the function call InternetOprn(...) Pls see below InternetOpenUrl Opens a resource specified by a complete FTP, Gopher, or HTTP URL. HINTERNET InternetOpenUrl( HINTERNET hInternet, LPCTSTR lpszUrl, LPCTSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD_PTR dwContext ); Parameters hInternet [in] Handle to the current Internet session. The handle must have been returned by a previous call to InternetOpen Plz correct me if I am wrong. What I could conclude from the MSDN excerpt is that "InternetOpen returns handle to the internet session if connected and if not it will return null, using this handle we can open an URL using InternetOpenURL() function". Also the exact use case is "check if user is connected to the internet". Thanks n Regards RuchirDhar Dwivedi. RuchirDhar Dwivedi Software Engineer Windowmaker Software Pvt.Ltd. Baroda, India.
RuchirD wrote: Windows function call InternetOpenURL uses Handle that is returned by the function call InternetOprn(...) Yeah you are RIght!,Sorry i Interpreted it wrong. RuchirD wrote: What I could conclude from the MSDN excerpt is that "InternetOpen returns handle to the internet session if connected and if not it will return null, using this handle we can open an URL using InternetOpenURL() function". InternetOpen according to MSDN "InternetOpen is the first Win32 Internet function called by an application. It tells the Internet DLL to initialize internal data structures and prepare for future calls from the application." So it just Initializing the Local Variable ONly , not checking the State of Internet.i.e. you can simulate the use of Internet api using
LOCAL WebServer
. ButInternetGetConnectedState
return with actual Internet State. TRY IT!
"I Think this Will Help"
visit me at http://www.thisisalok.tk
-
RuchirD wrote: Windows function call InternetOpenURL uses Handle that is returned by the function call InternetOprn(...) Yeah you are RIght!,Sorry i Interpreted it wrong. RuchirD wrote: What I could conclude from the MSDN excerpt is that "InternetOpen returns handle to the internet session if connected and if not it will return null, using this handle we can open an URL using InternetOpenURL() function". InternetOpen according to MSDN "InternetOpen is the first Win32 Internet function called by an application. It tells the Internet DLL to initialize internal data structures and prepare for future calls from the application." So it just Initializing the Local Variable ONly , not checking the State of Internet.i.e. you can simulate the use of Internet api using
LOCAL WebServer
. ButInternetGetConnectedState
return with actual Internet State. TRY IT!
"I Think this Will Help"
visit me at http://www.thisisalok.tk
Hi Thanks for information. I m Still having some doubt and some confusion. Coming to doubt:- I want to know whether user is connected to the internet it should not be application's concern that user is connected to the internet via LAN/PROXY/DIALUP. How to do that?? (connected to internet means connection is esatblished not just that internet is configured.) Coming to Confusion:- As you said that the InternetOpen according to MSDN "InternetOpen is the first Win32 Internet function called by an application. It tells the Internet DLL to initialize internal data structures and prepare for future calls from the application." but in the description of InternetOpen they say InternetOpen For a general utility or application, you should start with the InternetOpen function. By specifying the Internet agent you want to do the Internet access (for example, Microsoft Internet Explorer), the type of access you want, and a few optional flags, this function returns you a handle to an Internet session. When you are finished with the connection, you must close it by passing the handle to the InternetCloseHandle function. For example: HINTERNET hInternetSession; hInternetSession = InternetOpen( "Microsoft Internet Explorer", // agent INTERNET_OPEN_TYPE_PRECONFIG, // access NULL, NULL, 0); // defaults . . . InternetCloseHandle(hInternetSession); This will make a connection to the Internet, using the Internet agent "Microsoft Internet Explorer," and return a handle to the connection, if successful. By specifying the parameter INTERNET_OPEN_TYPE_PRECONFIG, you have requested the agent to use certain values that are stored in the registry. The rest of the parameters are set to use the default configurations. In one simple call, you have made a connection to the Internet—assuming nothing went wrong with the connection, of course! With the returned hInternetSession handle used as a parameter to the other functions, you can start accessing Internet information. So Which one to prefer and am I interpreting correct that this call will make connection and return internet session as handle. RuchirDhar Dwivedi Software Engineer Windowmaker Software Pvt.Ltd. Baroda, India.
-
Hi I am writing an application which needs to know if the user is having internet connection enabled or not. I want this checking to be done automatically by the application, I donot want to pop up connect internet dialog. Can anyone tell me if there is any API/function to findout that the machine is having internet connection. Regards, Ruchirdhar Dwivedi RuchirDhar Dwivedi Software Engineer Windowmaker Software Pvt.Ltd. Baroda, India.
See the FAQ 8.7 How do I tell if the computer is connected to the Internet?[^] --Mike-- LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb Strange things are afoot at the U+004B U+20DD
-
Hi I am writing an application which needs to know if the user is having internet connection enabled or not. I want this checking to be done automatically by the application, I donot want to pop up connect internet dialog. Can anyone tell me if there is any API/function to findout that the machine is having internet connection. Regards, Ruchirdhar Dwivedi RuchirDhar Dwivedi Software Engineer Windowmaker Software Pvt.Ltd. Baroda, India.
See here.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow