Jump to content

Wininet.dll


Recommended Posts

Larry

May I know how to use this in dllcall?

Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef _

lpSFlags As Long, ByVal dwReserved As Long) As Long

Const INTERNET_CONNECTION_MODEM = 1

Const INTERNET_CONNECTION_LAN = 2

Const INTERNET_CONNECTION_PROXY = 4

Const INTERNET_CONNECTION_MODEM_BUSY = 8

' return True if there is an active Internect connection

'

' optionally returns the connection mode through

' its argument (see INTERNET_CONNECTION_* constants)

' 1=modem, 2=Lan, 4=proxy

' 8=modem busy with a non-internet connection

Link to comment
Share on other sites

Larry

May I know how to use this in dllcall?

Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef _

    lpSFlags As Long, ByVal dwReserved As Long) As Long

Const INTERNET_CONNECTION_MODEM = 1

Const INTERNET_CONNECTION_LAN = 2

Const INTERNET_CONNECTION_PROXY = 4

Const INTERNET_CONNECTION_MODEM_BUSY = 8

' return True if there is an active Internect connection

'

' optionally returns the connection mode through

' its argument (see INTERNET_CONNECTION_* constants)

'   1=modem, 2=Lan, 4=proxy

'   8=modem busy with a non-internet connection

<{POST_SNAPBACK}>

Here's an example:

I added InternetGetConnectedStateEx in case you want to get the connection name as well.

; Flags for InternetGetConnectedState
Global $INTERNET_CONNECTION_MODEM = 0x01      ; 1
Global $INTERNET_CONNECTION_LAN = 0x02        ; 2
Global $INTERNET_CONNECTION_PROXY = 0x04      ; 4
Global $INTERNET_RAS_INSTALLED = 0x10          ; 16
Global $INTERNET_CONNECTION_OFFLINE = 0x20    ; 32
Global $INTERNET_CONNECTION_CONFIGURED = 0x40  ; 64

Dim $aDllRet
Dim $nConnectedState
Dim $sConnectionName

$aDllRet = DllCall("wininet.dll", "int", "InternetGetConnectedState", "long_ptr", 0, "long", 0)
If Not @error And $aDllRet[0] <> 0 Then
   $nConnectedState = $aDllRet[1]
   MsgBox(4096,'debug line ~5' , '$nConnectedState:' & @lf & $nConnectedState);### Debug MSGBOX
EndIf

$aDllRet = DllCall("wininet.dll", "int", "InternetGetConnectedStateEx", "long_ptr", 0, "str", "", "long", 512, "long", 0)
If Not @error And $aDllRet[0] <> 0 Then
   $nConnectedState = $aDllRet[1]
MsgBox(4096,'debug line ~21' , '$nConnectedState:' & @lf & $nConnectedState);### Debug MSGBOX
   $sConnectionName = $aDllRet[2]
MsgBox(4096,'debug line ~23' , '$sConnectionName:' & @lf & $sConnectionName);### Debug MSGBOX   
EndIf

; Here's how you can use the connected state value
If BitAND($nConnectedState, $INTERNET_CONNECTION_MODEM) Then
   MsgBox(4096, "", "MODEM")
EndIf

If BitAND($nConnectedState, $INTERNET_CONNECTION_LAN) Then
   MsgBox(4096, "", "LAN")
EndIf

If BitAND($nConnectedState, $INTERNET_CONNECTION_PROXY) Then
   MsgBox(4096, "", "PROXY")
EndIf

If BitAND($nConnectedState, $INTERNET_RAS_INSTALLED) Then
   MsgBox(4096, "", "RAS INSTALLED")
EndIf

If BitAND($nConnectedState, $INTERNET_CONNECTION_OFFLINE) Then
   MsgBox(4096, "", "OFFLINE")
EndIf

If BitAND($nConnectedState, $INTERNET_CONNECTION_CONFIGURED) Then
   MsgBox(4096, "", "CONFIGURED")
EndIf
Edited by pacman
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...