-1

我使用以下链接http://www.muukka.net/programming/service/Beeper%20Service.cpp编写服务。但这里的问题是,只有在请求停止服务时才会调用 servicemain 函数。

我想事先启动 servicemain 功能,以检测连接的 USB 设备.. 我该怎么办..

4

1 回答 1

1

在代码中:

SC_HANDLE service = CreateService( serviceControlManager, serviceName, serviceName, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START , SERVICE_ERROR_IGNORE, path, 0, 0, 0, 0, 0);

改成:

SC_HANDLE service = CreateService(serviceControlManager, serviceName, serviceName, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_DEMAND_START , SERVICE_ERROR_IGNORE, path, 0, 0, 0, 0, 0);

也试试这个:http: //msdn.microsoft.com/en-us/library/windows/desktop/bb540476%28v=vs.85%29.aspx

于 2012-05-19T10:21:42.430 回答