cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Roman1
Level 9

Check if Internet Connection Available

Hello,
I am trying to check if PC could connect to Internet.


The check function Wininet.InternetCheckConnectionA does not come back.
What could be wrong?

Has anybody an idea how to test Internet Connection?

Regards



#define FLAG_ICC_FORCE_CONNECTION 0x01
prototype BOOL Wininet.InternetCheckConnectionA(BYREF STRING, NUMBER, NUMBER);

UseDLL(WINSYSDIR ^ "\\Wininet.dll")

bInternetAvailable = Wininet.InternetCheckConnectionA("WWW.google.com", FLAG_ICC_FORCE_CONNECTION, 0);
Labels (1)
0 Kudos
(4) Replies
vinodn1
Level 4

Did you get this to work? I am also looking for a good way to check if an internet connection exists. Thanks.
0 Kudos
rguggisberg
Level 13

If you can use a CA, launch a command that executes the PING command.
Flexera's security rules for this site prevent me from posting an example. 😞
0 Kudos
TurboFisch
Level 7

ping is not a good approach, because the firewall might be preventing pings.

ipconfig might be better and then you can check if the Ip address is valid.
0 Kudos
sdnelson
Level 5

ipconfig won't work. Most devices connect through a router so testing for network connectivity is not the same as checking for access to the internet. You need to make a call outside of the network and receive an expected response to determine access to the internet. Microsoft uses NCSI (Network Connectivity Status Indicator) There are 2 ways.

1) Have the installer download http://www.msftncsi.com/ncsi.txt and check that you receive it. This is a plain text file containing the text "Microsoft NCSI"
OR
2) Perform a DNS lookup on dns.msftncsi.com and verify the IP is 131.107.255.255. If not, assume there is no internet access.
0 Kudos