IsNetworkAlive

Erdenemandal

Regular
Joined
Jul 5, 2004
Messages
63
Location
Deutschland
Hi, ALL

I have a question. I use a function, checks a network connection

Code:
  Private Declare Function IsNetworkAlive Lib "SENSAPI.DLL" ( _
                ByRef lpdwFlags As Integer) _
        As Long

but I returns me TRUE , even I disconnected a networkcable.

Can somebody say WHY

Thanks,
Erdenemandal
 
Here is a example I found that might help a little

Code:
Const NETWORK_ALIVE_AOL = &H4
Const NETWORK_ALIVE_LAN = &H1
Const NETWORK_ALIVE_WAN = &H2
Private Declare Function IsNetworkAlive Lib "SENSAPI.DLL" (ByRef lpdwFlags As Long) As Long
Private Sub Form_Load()
    'KPD-Team 2001
    'URL: [url]http://www.allapi.net/[/url]
    'E-Mail: [email]KPDTeam@Allapi.net[/email]
    Dim Ret As Long
    If IsNetworkAlive(Ret) = 0 Then
        MsgBox "The local system is not connected to a network!"
    Else
        MsgBox "The local system is connected to a " + IIf(Ret = NETWORK_ALIVE_AOL, "AOL", IIf(Ret = NETWORK_ALIVE_LAN, "LAN", "WAN")) + " network!"
    End If
End Sub
 
Some result

Yeah, I am using Micrsoft Visual Basic NET.
Net Framework 1.1

when I run your script, it shows me a form with Button1. When I press it a messages is "The local system is connected to a LAN network!"
May be do I need to download SENSAPI.DLL ?

Thanks,
 
And that is displayed even when not connected to the network? I did not download anything special to run this code, when I take the cable out and press the button, it tells me it is down. Hmmm..
 
Hmmm

Rick_Fla said:
And that is displayed even when not connected to the network? I did not download anything special to run this code, when I take the cable out and press the button, it tells me it is down. Hmmm..


Strange, I don't know really. I took a cable out, and Run it again. But it always says something.

Hmmm... I am using Windows XP prof.
 
Using XP pro myself.

Either way it should pop up with a message, but one says "The local system is not connected to a network!" and the other says you are connected.

Got me stumped now. I have a VB6 app that is working with it, I could send it to you and let you try it as well. Uses the same Declare as the sample above. It checks every second and will display in green or red. So you could have the cable in and the pull it out while running and it should switch over.

Let me know if you would like to try it.
 
Rick_Fla said:
Using XP pro myself.

Either way it should pop up with a message, but one says "The local system is not connected to a network!" and the other says you are connected.

Got me stumped now. I have a VB6 app that is working with it, I could send it to you and let you try it as well. Uses the same Declare as the sample above. It checks every second and will display in green or red. So you could have the cable in and the pull it out while running and it should switch over.

Let me know if you would like to try it.

Thanks, But I won't do it. Because I tested my script also in VB6. It works . But I have a problem just with VB.NET !!. Strange.
 
Back
Top