Jump to content
Sign in to follow this  
WhiteTiger

Checkinet

Recommended Posts

func checkinet()
$f_con = DllCall("wininet.dll","Dword","InternetAttemptConnect")
if $f_con <> 0 then 
    DllCall("wininet.dll","dword","InternetAttemptConnect")
    $f_con = DllCall("wininet.dll","Dword","InternetAttemptConnect")
if $f_con <> 0 then 
    Return -1
EndIf
EndIf
$f_open = DllCall("wininet.dll","dword","InternetOpen","Dword","dwAccesType")
if not $f_open = 0 then Return $f_open
EndFunc

This will return 0 if connecton is good , else it wil return a systemError number :-)

i hope some-one might think its usefull :-)

Share this post


Link to post
Share on other sites

What are the chances of both google and Microsoft being down?

Works fine here. Nice function :whistle:

Share this post


Link to post
Share on other sites

You call "InternetAttemptConnect" 3 times if ok connection?, but then call "InternetOpen" when no connection exists which opens a handle which you may need to close with "InternetCloseHandle". The UDF seems to be incomplete.

Share this post


Link to post
Share on other sites

You call "InternetAttemptConnect" 3 times if ok connection?, but then call "InternetOpen" when no connection exists which opens a handle which you may need to close with "InternetCloseHandle". The UDF seems to be incomplete.

nope :-) it checks if there's is a connection , if it inst , it try's to connect , if it still isnt online then it returns an error , else it prepare's a connection , just in case windows doesnt do this automaticly :-)

and thanks for the nice reply's

Share this post


Link to post
Share on other sites

But with Microsoft's track record, the only thing that would end up with issues would be the ALICE implementation and then the frustration from dealing with an artificially stupid operating system would drive people to other issues.

Share this post


Link to post
Share on other sites

; $IsCon[0] = 0 not connected, $IsCon[0] = 1 is connec.

$IsCon=DllCall("WinInet.dll","int","InternetGetConnectedState","int_ptr",0,"int",0)

MsgBox(4096,"",$IsCon[0])

short and sweet

sorry, a type error corrected

Edited by Rick

Who needs puzzles when we have AutoIt!!

Share this post


Link to post
Share on other sites

; 0 = not connected 1 is connected.

$IsCon=DllCall("WinInet.dll","int","InternetGetConnectedState","int_ptr",0,"int",0)

MsgBox(4096,"",$IsCon[0])

short and sweet

Very nice but how do you wrap around a while or do statement that requires the result to the dllcall to be 1 before continuing to run the script? Ant

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  

×
×
  • Create New...