PDA

Click to See Complete Forum and Search --> : Connection Status


blglas
Dec 9th, 2000, 07:48 AM
Is there a good way to detect if a PC is connected via phone or Netwrok without using WININET.DLL?

satyaraj
Dec 11th, 2000, 04:52 AM
Write this code in a VB Project MODULE.bas

Option Explicit
Public Declare Function InternetGetConnectedState _
Lib "wininet.dll" (ByRef lpSFlags As Long, _
ByVal dwReserved As Long) As Long

Public Const INTERNET_CONNECTION_LAN As Long = &H2
Public Const INTERNET_CONNECTION_MODEM As Long = &H1

Public Function Online() As Boolean
Dim SFlags As Long
'If you are online it will return True, otherwise False
Online = InternetGetConnectedState(0, 0)
End Function

Public Function ViaLAN() As Boolean
Dim SFlags As Long
'return the flags associated with the connection
Call InternetGetConnectedState(INTERNET_CONNECTION_LAN, 0)

'True if the Sflags has a LAN connection
ViaLAN = SFlags And INTERNET_CONNECTION_LAN
End Function

Public Function ViaModem() As Boolean
Dim SFlags As Long
'return the flags associated with the connection
Call InternetGetConnectedState(INTERNET_CONNECTION_MODEM, 0)
'True if the Sflags has a modem connection
ViaModem = SFlags And INTERNET_CONNECTION_MODEM
End Function


NOW WRITE THE FOLLOWING CODE IN FORM HAVING 2 TEXT BOXES & A COMMAND BUTTON

Private Sub Command1_Click()
Text1 = ViaLAN()
Text2 = ViaModem()
Text3 = Online()
End Sub

But there is a bug in this program hope you'll be able to resolve it & get back to me. Atleast I've got you started with it.
BYE

blglas
Dec 11th, 2000, 03:50 PM
Thanks for the code sample. However, I'm trying to determine connection state using something other than WININET.DLL