InternetGetConnectedState and “it should not be us

2019-08-18 08:37发布

I'm programming a Windows local service using C++ and WinAPIs. From within that service I need to know that an Internet connection is available (in general) so I came up with the InternetGetConnectedState API but then after reading the MSDN I found this in the Remarks section:

In addition, it should not be used from a service.

Well, "thank you", Microsoft!

Does anyone have any idea why and what alternative can I use from a service.

PS. I don't want to use the ping approach because obviously there's no way of knowing that the site I'm pinging is up, so it then opens up a whole new can of worms.

1条回答
forever°为你锁心
2楼-- · 2019-08-18 08:56

Generally you don't need to care whether the Internet is available, you just attempt to make the connection to the site and deal with any failure.

查看更多
登录 后发表回答