InternetGetConnectedState和“它不应该从服务中使用”语句从MSDN [英] InternetGetConnectedState and "it should not be used from a service" statement from MSDN
问题描述
我正在使用C ++和WinAPI编写Windows本地服务。从服务内我需要知道一个互联网连接(一般),所以我想出了 InternetGetConnectedState
API,但是在阅读MSDN后,
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.
好的,谢谢,微软!
有没有人知道为什么,我可以从服务中使用什么替代方法。
Does anyone have any idea why and what alternative can I use from a service.
PS。我不想使用ping方法,因为显然没有办法知道我正在ping的网站是,所以它然后打开一个全新的可能的蠕虫。
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.
推荐答案
一般来说,您不需要关心互联网是否可用,您只是尝试连接到网站并处理任何失败。
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.
这篇关于InternetGetConnectedState和“它不应该从服务中使用”语句从MSDN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!