InternetGetConnectedState and “it should not be used from a service” statement from MSDN

落爺英雄遲暮 提交于 2019-12-24 18:25:42

问题


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:


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.



来源:https://stackoverflow.com/questions/11320366/internetgetconnectedstate-and-it-should-not-be-used-from-a-service-statement-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!