Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Help with Wininet.dll\InternetCheckConnection


  • Please log in to reply
9 replies to this topic
meter
  • Members
  • 29 posts
  • Last active: Jul 25 2008 03:18 PM
  • Joined: 12 Jul 2006
I am not a Windows programmer, and I don't play one on TV. Perhaps because of this, I can't figure out why my Wininet.dll\InternetCheckConnection call isn't working.

I want to do something similar to How to find Internet Connection Status but using Wininet.dll\InternetCheckConnection to check access to a given url.

I cobbled together the the beginnings of the funciton below, but when I call it, the error code indicates that InternetCheckConnection can't be found.

ConnectedToInternetURL(checkURL=0) {
   ; right now i am unconditionally sending 0 as URL's char ptr to force NULL
   rv := DllCall("Wininet.dll\InternetCheckConnection", "Int", 0, "Int", 0, "Int", 0)
   MsgBox, (Debug)`nResult: %rv%`nErrorLevel: %ErrorLevel%
   Return %rv%
} 

I've tried calling Wininet.dll\InternetCheckConnection with various combinations of arguments, but no matter what I try, InternetCheckConnection just can't be found; however InternetGetConnectedState works just fine. I am running XP Home SP2.

Any idea what I'm doing wrong?
-Meter

AhkMan
  • Guests
  • Last active:
  • Joined: --
You might want to search google groups for: InternetCheckConnection unreliable

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

I want to do something similar to How to find Internet Connection Status but using Wininet.dll\InternetCheckConnection to check access to a given url.


Re: TipsNTricks: How to find Internet Connection Status
I have updated and appended the post with an example for
Wininet.dll\InternetCheckConnection

Regards, :)
kWo4Lk1.png

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
You need to use InternetCheckConnectionA (for ANSI).

meter
  • Members
  • 29 posts
  • Last active: Jul 25 2008 03:18 PM
  • Joined: 12 Jul 2006
Awesome. Thanx!!!
-Meter

JoeSchmoe
  • Members
  • 304 posts
  • Last active: Feb 28 2013 05:39 PM
  • Joined: 17 Feb 2008

You need to use InternetCheckConnectionA (for ANSI).

I'm not a windows programmer and I don't play one on TV.

Is anyone willing to explain to me why there are three versions of "InternetCheckConnection," one with an "A" appended, one with a "W" appended, and one with nothing appended? I'm familiar with the distinction between ANSI and Unicode, but I don't know why Microsoft has to have different versions of its functions for each.

I'm curious because, as I begin trying to wade through MSDN, I'm not sure which version I should use with DLLCall.

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

I'm curious because, as I begin trying to wade through MSDN, I'm not sure which version I should use with DLLCall.


I highly recommend Ping : http://www.autohotke... ... 472#195472

JoeSchmoe
  • Members
  • 304 posts
  • Last active: Feb 28 2013 05:39 PM
  • Joined: 17 Feb 2008

I highly recommend Ping : http://www.autohotke... ... 472#195472

Interesting... I cam across that post when I was searching earlier, but thought that InternetCheckConnectionA would be better since:* I will probably preload wininet.dll in the script I'm thinking of and
* running ping.exe will require windows to fire up a new executableI'm curious, why do you recommend ping?

I'm also still curious about multiple versions of API calls. It seems like if I just use "InternetCheckConnection" that AutoHotkey or Windows or something would figure out that I need the Ascii version. Isn't that what is supposed to happen?

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

I highly recommend Ping

I'm curious, why do you recommend ping?


Ping is humble yet consistent.

None of these different API calls worked consistently for me in Win98 / 2k / XP / Vista for Dial-up vs WAN.

It seems like if I just use "InternetCheckConnection" that AutoHotkey or Windows or something would figure out that I need the Ascii version. Isn't that what is supposed to happen?


AHK would.. But I prefer using the exact exported function name.

acomber
  • Guests
  • Last active:
  • Joined: --
Actually there are only 2 versions - wide and ascii. Wide means the unicode version - you pass in unicode strings. A means ascii, ie you use ascii characters.

There is a #define which checks if you are compiling with UNICODE flag and if so W version is used, otherwise the ascii version.

I expect you will be safe to use the A version.