Diablicolic Posted August 5, 2003 Posted August 5, 2003 How can you tell if the user opening your program has an internet connection open? Quote "Reality is fake, Dreams are for real"
Leaders dynamic_sysop Posted August 5, 2003 Leaders Posted August 5, 2003 you need to try InternetGetConnectedState , here's a link that may help: checking for internet connection. Quote
*Experts* Volte Posted August 5, 2003 *Experts* Posted August 5, 2003 There is some VB6 code here. Not sure if it works or not since I have a DSL connection which is always on, but it can be easily be converted to VB.NET so you can try it. Quote
Diablicolic Posted August 6, 2003 Author Posted August 6, 2003 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Example by Vijay Phulwadhawa (vijaycg44@hotmail.com) IsConnected() MsgBox("Is connected to the internet: " + CStr(IsConnected())) End Sub Public Function IsConnected() As Boolean If InternetGetConnectedState(0&, 0&) = 1 Then IsConnected = True Else IsConnected = False End If End Function It always says false :( Oh yeah and I have this where the global variables are: Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long Quote "Reality is fake, Dreams are for real"
Leaders dynamic_sysop Posted August 6, 2003 Leaders Posted August 6, 2003 you need to change the Longs to Integers , also in a Boolean Function , use the Return method ( eg: Return True ), here's a quick example : Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Integer, ByVal dwReserved As Integer) As Integer '/// use Integers , not Longs. '/// Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MessageBox.Show(CheckConnectionState) End Sub Private Function CheckConnectionState() As Boolean Dim ConnectionState As Integer = InternetGetConnectedState(vbNullString, vbNullString) If ConnectionState = 1 Then Return True Else Return False End If End Function :) Quote
Diablicolic Posted August 6, 2003 Author Posted August 6, 2003 yay :p Quote "Reality is fake, Dreams are for real"
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.