Jump to content

Checking network card statuses


CBuckley
 Share

Recommended Posts

Chris,

My suggestion is to use the following:

$ChecK_It = IsAlive()
If StringInStr($ChecK_It, "Not Connected") OR StringInStr($ChecK_It, "OffLine") Then
    MsgBox(0, "", "")
EndIf

Func IsAlive()
   Ping('www.google.com',3000)
   $Internet_Connection_Modem = 0x1
   $Internet_Connection_Lan = 0x2
   $Internet_Connection_Proxy = 0x4
   $Internet_Connection_Modem_Busy = 0x8
   $Internet_Ras_Installed = 0x10
   $Internet_Connection_Offline = 0x20
   $Internet_Connection_Configured = 0x40
   $Ret = DllCall ("WinInet.dll", "int", "InternetGetConnectedState", "int_ptr", 0, "int", 0)
   If $Ret[0] then
    ;check type of connection
      $Sx = ""
      If BitAND ($Ret[1], $Internet_Connection_Modem) Then $Sx = $Sx & "MODEM" & @LF
      If BitAND ($Ret[1], $Internet_Connection_Lan) Then $Sx = $Sx & "LAN" & @LF
      If BitAND ($Ret[1], $Internet_Connection_Proxy) Then $Sx = $Sx & "PROXY" & @LF
      If BitAND ($Ret[1], $Internet_Connection_Modem_Busy) Then $Sx = $Sx & "MODEM_BUSY" & @LF
      If BitAND ($Ret[1], $Internet_Ras_Installed) Then $Sx = $Sx & "RAS_INSTALLED" & @LF
      If BitAND ($Ret[1], $Internet_Connection_Offline) Then $Sx = $Sx & "OFFLINE" & @LF
      If BitAND ($Ret[1], $Internet_Connection_Configured) Then $Sx = $Sx & "CONFIGURED" & @LF
   Else
      $Sx = "Not Connected"
   Endif
   Return $Sx
EndFunc ;<==> Is_Alive()

However, if you have two or more network devices, this will require both of them to be disconnected. Perhaps turn WiFi off if you were to have it enabled.

James

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...