Sign in to follow this  
Followers 0
CBuckley

Checking network card statuses

4 posts in this topic

Hello, I was just wondering if there was a way to check if a specific network interface was not connected on my computer and then use this to warn the user.

Thanks,

Chris

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

Yeah, I tried something similar but the problem being is that it really does need to be dependant on one of my NIC's rather than both. I thought maybe winsock but I haven't used winsock since winsock one and even then I wasn't too good at it.

Share this post


Link to post
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
Sign in to follow this  
Followers 0