sjchin
asked on
Any sample vb6 code to detect wireless?
Hi guys, assume i using 2 notebook doing a wireless connection. Does any vb6 sample code can detect does the other notebook has been detected or can't able be connect? or any simple way to detect it and can using vb6 to call it out? Thanks you.
If you know the IP of the other notebook could you not use something like ping and create a watchdog from the result.
ASKER
any sample can do this?example in VB6 or vb.net?
Not all my own work but this will give you a message box when IP becomes active, and one when it becomes inactive I have used a timer to trigger the check so set timer1 to a suitable sample time. The IP is written in the code so you probably want to pretty this up a little:-
Private Declare Function GetRTTAndHopCount Lib "iphlpapi.dll" _
(ByVal lDestIPAddr As Long, _
ByRef lHopCount As Long, _
ByVal lMaxHops As Long, _
ByRef lRTT As Long) As Long
Private Declare Function inet_addr Lib "wsock32.dll" _
(ByVal cp As String) As Long
Public LastPing As String
Public FoundIt As String
Public IPWatchDog As String
Public Function SimplePing(sIPadr As String) As Boolean
' Based on an article on 'Codeguru' by 'Bill Nolde'
' Thx to this guy! It 's simple and great!
' Implemented for VB in November 2002 by G. Wirth, Ulm, Germany
' Enjoy!
Dim lIPadr As Long
Dim lHopsCount As Long
Dim lRTT As Long
Dim lMaxHops As Long
Dim lResult As Long
Const SUCCESS = 1
lMaxHops = 20 ' should be enough ...
lIPadr = inet_addr(sIPadr)
SimplePing = (GetRTTAndHopCount(lIPadr, lHopsCount, lMaxHops, lRTT) = SUCCESS)
LastPing = SimplePing
End Function
Private Sub Timer1_Timer()
IPWatchDog = "10.0.0.50"
Call SimplePing(IPWatchDog)
If FoundIt = "Active" Then GoTo WatchDog
If LastPing = True Then MsgBox ("Found " & IPWatchDog & " Monitoring is active")
If LastPing = True Then FoundIt = "Active"
If FoundIt = "Inactive" Then GoTo Waiting
WatchDog:
If LastPing = False Then MsgBox ("Lost communications to " & IPWatchDog)
If LastPing = False Then FoundIt = "Inactive"
Waiting:
End Sub
Private Declare Function GetRTTAndHopCount Lib "iphlpapi.dll" _
(ByVal lDestIPAddr As Long, _
ByRef lHopCount As Long, _
ByVal lMaxHops As Long, _
ByRef lRTT As Long) As Long
Private Declare Function inet_addr Lib "wsock32.dll" _
(ByVal cp As String) As Long
Public LastPing As String
Public FoundIt As String
Public IPWatchDog As String
Public Function SimplePing(sIPadr As String) As Boolean
' Based on an article on 'Codeguru' by 'Bill Nolde'
' Thx to this guy! It 's simple and great!
' Implemented for VB in November 2002 by G. Wirth, Ulm, Germany
' Enjoy!
Dim lIPadr As Long
Dim lHopsCount As Long
Dim lRTT As Long
Dim lMaxHops As Long
Dim lResult As Long
Const SUCCESS = 1
lMaxHops = 20 ' should be enough ...
lIPadr = inet_addr(sIPadr)
SimplePing = (GetRTTAndHopCount(lIPadr,
LastPing = SimplePing
End Function
Private Sub Timer1_Timer()
IPWatchDog = "10.0.0.50"
Call SimplePing(IPWatchDog)
If FoundIt = "Active" Then GoTo WatchDog
If LastPing = True Then MsgBox ("Found " & IPWatchDog & " Monitoring is active")
If LastPing = True Then FoundIt = "Active"
If FoundIt = "Inactive" Then GoTo Waiting
WatchDog:
If LastPing = False Then MsgBox ("Lost communications to " & IPWatchDog)
If LastPing = False Then FoundIt = "Inactive"
Waiting:
End Sub
I also have a fully working exe version with interface if that is any help.
ASKER
Do you mind to give me the working exe?
if can please email to sjchin@hotmail.com
Thank you.
if can please email to sjchin@hotmail.com
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.