|
-
Sep 27th, 2000, 04:05 PM
#1
Thread Starter
Addicted Member
I used the following code provided by Matthew Gates to detect an Internet connection. I am making this program for a friend, and it works perfectly on my computer, but not on his. It won't detect the connection. I think the reason for this is that he's using AOL. Any ideas?
Code:
Code:
Public Declare Function RasEnumConnections Lib "RasApi32.dll" Alias "RasEnumConnectionsA" (lpRasCon As Any, lpcb As Long, lpcConnections As Long) As Long
Public Declare Function RasGetConnectStatus Lib "RasApi32.dll" Alias "RasGetConnectStatusA" (ByVal hRasCon As Long, lpStatus As Any) As Long
'
Public Const RAS95_MaxEntryName = 256
Public Const RAS95_MaxDeviceType = 16
Public Const RAS95_MaxDeviceName = 32
'
Public Type RASCONN95
dwSize As Long
hRasCon As Long
szEntryName(RAS95_MaxEntryName) As Byte
szDeviceType(RAS95_MaxDeviceType) As Byte
szDeviceName(RAS95_MaxDeviceName) As Byte
End Type
'
Public Type RASCONNSTATUS95
dwSize As Long
RasConnState As Long
dwError As Long
szDeviceType(RAS95_MaxDeviceType) As Byte
szDeviceName(RAS95_MaxDeviceName) As Byte
End Type
Public Function IsConnected() As Boolean
Dim TRasCon(255) As RASCONN95
Dim lg As Long
Dim lpcon As Long
Dim RetVal As Long
Dim Tstatus As RASCONNSTATUS95
'
TRasCon(0).dwSize = 412
lg = 256 * TRasCon(0).dwSize
'
RetVal = RasEnumConnections(TRasCon(0), lg, lpcon)
If RetVal <> 0 Then
MsgBox "ERROR"
Exit Function
End If
'
Tstatus.dwSize = 160
RetVal = RasGetConnectStatus(TRasCon(0).hRasCon, Tstatus)
If Tstatus.RasConnState = &H2000 Then
IsConnected = True
Else
IsConnected = False
End If
End Function
Usage:
Private Sub Command1_Click()
If IsConnected() <> 0 Then
Msgbox "Connected!"
Else
Msgbox "Not Connected!"
End If
End Sub
- Visual Basic 6.0
- Windows XP Home
-
Sep 27th, 2000, 04:09 PM
#2
Lively Member
this code is usable as long as you are u sing ras connections...meaning dialup
YC Sim
Teenage Programmer
UIN 37903254
-
Sep 27th, 2000, 04:14 PM
#3
Thread Starter
Addicted Member
Does anyone know how I can tell if AOL is connected, then?
- Visual Basic 6.0
- Windows XP Home
-
Sep 27th, 2000, 04:41 PM
#4
For AOL:
Code:
Private Function AOL() As Boolean
Dim aolframe As Long, mdiclient As Long, aolchild As Long
aolframe = FindWindow("aol frame25", vbNullString)
mdiclient = FindWindowEx(aolframe, 0&, "mdiclient", vbNullString)
aolchild = FindWindowEx(mdiclient, 0&, "aol child", vbNullString)
aolchild = FindWindowEx(mdiclient, aolchild, "aol child", vbNullString)
If aolchild <> 0 Then
AOL = True
Else
AOL = False
End If
End Function
Usage:
Private Sub Command1_Click()
If AOL() Then
MsgBox "Connected"
Else
MsgBox "Not Connected"
End If
End Sub
-
Sep 28th, 2000, 09:00 AM
#5
Thread Starter
Addicted Member
Thank you very much again! My friend says it works.
- Visual Basic 6.0
- Windows XP Home
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|