R RS Sep 3, 2003 #1 Is there a function that will tell you if your computer is online to the internet ?
W William Ryan Sep 3, 2003 #2 There are two way that come to mind //Using WinAPI - make sure you use Runtime.Interopservices [DllImport("wininet.dll")] private extern static bool InternetGetConnectedState( int out Description, int ReservedValue ) ; public static bool IsConnected( ) { int Desc ; return InternetGetConnectedState( out Desc, 0 ) ; } or this way...
There are two way that come to mind //Using WinAPI - make sure you use Runtime.Interopservices [DllImport("wininet.dll")] private extern static bool InternetGetConnectedState( int out Description, int ReservedValue ) ; public static bool IsConnected( ) { int Desc ; return InternetGetConnectedState( out Desc, 0 ) ; } or this way...
W William Ryan Sep 3, 2003 #3 Two come to mind Dim webRequestor As HttpWebRequest Dim webResponder As HttpWebResponse Dim url As String = ConfigurationSettings.AppSettings.Item("url").ToString Try webRequestor = CType(WebRequest.Create(url), System.Net.HttpWebRequest) webResponder = CType(webRequestor.GetResponse, System.Net.HttpWebResponse) If webResponder.StatusCode = HttpStatusCode.OK Then Return True Or using the winAPI Make sure you include Runtime.InteropServices; [DllImport("wininet.dll")] private extern static bool InternetGetConnectedState( int out Description, int ReservedValue ) ; //Creating a function that uses the API function... public static bool IsConnected( ) { int Desc ; return InternetGetConnectedState( out Desc, 0 ) ; }
Two come to mind Dim webRequestor As HttpWebRequest Dim webResponder As HttpWebResponse Dim url As String = ConfigurationSettings.AppSettings.Item("url").ToString Try webRequestor = CType(WebRequest.Create(url), System.Net.HttpWebRequest) webResponder = CType(webRequestor.GetResponse, System.Net.HttpWebResponse) If webResponder.StatusCode = HttpStatusCode.OK Then Return True Or using the winAPI Make sure you include Runtime.InteropServices; [DllImport("wininet.dll")] private extern static bool InternetGetConnectedState( int out Description, int ReservedValue ) ; //Creating a function that uses the API function... public static bool IsConnected( ) { int Desc ; return InternetGetConnectedState( out Desc, 0 ) ; }
F Fergus Cooney Sep 4, 2003 #4 Hi William, Thanks for that. I've wondered myself. MSDN says that InternetGetConnectedState() will tell me whether there's a (default) connection or not. Do you know how I can tell more, eg, what's flowing on it - ie, whether there's an incoming stream or anything outgoing from other applications ? Thanks, Fergus
Hi William, Thanks for that. I've wondered myself. MSDN says that InternetGetConnectedState() will tell me whether there's a (default) connection or not. Do you know how I can tell more, eg, what's flowing on it - ie, whether there's an incoming stream or anything outgoing from other applications ? Thanks, Fergus