Sign in to follow this  
Followers 0
Prime

And.... The Error Is.... Here

6 posts in this topic

Hi,

I have a problem using the command "DLLCALL"!

I try to better explain:

I want to make a little programm that can check if I am online or not using a function inside the WININET.dll; this function is "InternetGetconnectedState".

To get some more info I go to the microsoftwebsite and the result of my search was this:

link to the page: MSDN for Internetgetconnectedstate

Windows Internet    
InternetGetConnectedState

Retrieves the connected state of the local system.

BOOL InternetGetConnectedState(
  LPDWORD lpdwFlags,
  DWORD dwReserved
);
Parameters
lpdwFlags
[out] Pointer to a variable that receives the connection description. This parameter may return a valid flag even when the function returns FALSE. This parameter can be one or more of the following values.
Value   Meaning 
INTERNET_CONNECTION_CONFIGURED
0x40    Local system has a valid connection to the Internet, but it might or might not be currently connected.  
INTERNET_CONNECTION_LAN 
0x02    Local system uses a local area network to connect to the Internet.  
INTERNET_CONNECTION_MODEM
0x01    Local system uses a modem to connect to the Internet.   
INTERNET_CONNECTION_MODEM_BUSY
0x08    No longer used. 
INTERNET_CONNECTION_OFFLINE 
0x20    Local system is in offline mode.    
INTERNET_CONNECTION_PROXY
0x04    Local system uses a proxy server to connect to the Internet.    
dwReserved
[in] Reserved. Must be zero.
Return Values

After this I try to create the programm but the result of my function is always equal to zero ( if I am connected or not to internet... always zero... :think::(:);) )

This is my code

#include <GUIConstants.au3>
#NoTrayIcon
GUICreate("Connected", 240, 70)
GUICtrlCreateGroup("Check if U are connected", 15, 15, 210, 50)
$info = GUICtrlCreateButton("Check", 30, 35, 180, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $info
            _consta()
    EndSelect   
WEnd
GUIDelete()
Func _consta($n ='',$last = 0)
    global $contoint = DllCall('wininet.dll', 'long', 'InternetGetconnectedState', 'ptr', $n, 'long', $last)
    MsgBox ( 0, "RESULT", $contoint )
    MsgBox ( 0, "There are ERRs?", @error )
EndFunc
Exit

Please someone help me to find the error :(:D:(:D

Share this post


Link to post
Share on other sites



#include <GUIConstants.au3>
#NoTrayIcon
GUICreate("Connected", 240, 70)
GUICtrlCreateGroup("Check if U are connected", 15, 15, 210, 50)
$info = GUICtrlCreateButton("Check", 30, 35, 180, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $info
            _consta()
    EndSelect
WEnd
Exit

Func _consta($n = '', $last = 0)
    Local $INTERNET_CONNECTION_CONFIGURED = 0x40;Local system has a valid connection to the Internet, but it might or might not be currently connected.
    Local $INTERNET_CONNECTION_LAN = 0x02;Local system uses a local area network to connect to the Internet.
    Local $INTERNET_CONNECTION_MODEM = 0x01;Local system uses a modem to connect to the Internet.
    Local $INTERNET_CONNECTION_MODEM_BUSY = 0x08;No longer used.
    Local $INTERNET_CONNECTION_OFFLINE = 0x20;Local system is in offline mode.
    Local $INTERNET_CONNECTION_PROXY = 0x04;Local system uses a proxy server to connect to the Internet.
    Local $s_connect, $struct
    
    $struct = DllStructCreate("int")
    Local $contoint = DllCall('Wininet.dll', 'int', 'InternetGetConnectedState', 'ptr', DllStructGetPtr($struct), 'int', 0)
    If @error Then
        MsgBox(0, "There are ERRs?", @error)
    ElseIf IsArray($contoint) Then
        If BitAND(DllStructGetData($struct, 1), $INTERNET_CONNECTION_CONFIGURED) = $INTERNET_CONNECTION_CONFIGURED Then
            $s_connect = "INTERNET CONNECTION CONFIGURED" & @LF
        EndIf
        If BitAND(DllStructGetData($struct, 1), $INTERNET_CONNECTION_LAN) = $INTERNET_CONNECTION_LAN Then
            $s_connect = $s_connect & "Connected to LAN" & @LF
        EndIf
        If BitAND(DllStructGetData($struct, 1), $INTERNET_CONNECTION_MODEM) = $INTERNET_CONNECTION_MODEM Then
            $s_connect = $s_connect & "Connected to Modem" & @LF
        EndIf
        If BitAND(DllStructGetData($struct, 1), $INTERNET_CONNECTION_OFFLINE) = $INTERNET_CONNECTION_OFFLINE Then
            $s_connect = $s_connect & "Offline" & @LF
        EndIf
        If BitAND(DllStructGetData($struct, 1), $INTERNET_CONNECTION_PROXY) = $INTERNET_CONNECTION_PROXY Then
            $s_connect = $s_connect & "System uses a proxy server" & @LF
        EndIf
    EndIf
    MsgBox(0, "RESULT", $s_connect)
    $struct = 0
EndFunc  ;==>_consta


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Tnx Gafrost for your rapid help... but the result said always.. that I am OFFLINE... but I am online... Boh! :think::(

Tnx again for your help

Share this post


Link to post
Share on other sites

Gary... i was connected with Firefox, and recieved a blank message box from the script.

then i connected with IE and the script gave me a "lan" connection

so it was blank until i ran IE

???

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Gary... i was connected with Firefox, and recieved a blank message box from the script.

then i connected with IE and the script gave me a "lan" connection

so it was blank until i ran IE

???

8)

Requires Internet Explorer 4.0 or later.


SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Requires Internet Explorer 4.0 or later.

Yeah! with IE works correctly ^^

tnx man :think:

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