JohnLM 14 Posted September 8 Specs: Delphi XE7, 11 and 12, VCL, Win7/10 I work mainly on my win7 latop. And there is this file that I check for stats purpsoes every day and throughout the day as I am working on the laptop. And in one instance today, it dawned on me that I need to know if I was connected to the internet or not. Plus, a side bonus could be helpful to know that if I lose internet I could do something about it. In win7 I noticed that in the bottom task tray area, there is the icon, the one with the square monitor looking image (sure its different in win10), when I hover the mouse over it or click on it, it will say, "Internet access" Is there some delphi code-snippet already out there that will tell me that I am connected to the internet, like in the above mentioned? Share this post Link to post
Remy Lebeau 1394 Posted September 8 (edited) On Windows, you can use the Network List Manager API, specifically the INetworkListManager.isConnectedToInternet property. However, as there are so many different ways that a PC can be connected to the Internet nowadays, you are better off simply trying to access an online resource (such as your status file) and see if it succeeds or fails, don't even bother polling the Internet status beforehand. That just introduces a TOCTOU race condition. Edited September 8 by Remy Lebeau 1 Share this post Link to post
Angus Robertson 574 Posted September 9 ICS includes an TIcsInetAlive component to check for IPv4 and/or IPv6 internet connectivity, using Ping and/or HTTP, to the same Microsoft servers that Windows uses to detect the internet, www.msftconnecttest.com and ipv6.msftconnecttest.com. Angus Share this post Link to post