Service::serviceCtlHandler(DWORD OpCode)
{
//...
}
Service::ServiceStart
{
//...
serviceStatusHandle = RegisterServiceCtrlHandler("Service", &Service开发者_JAVA百科::serviceCtrlHandler /*incompatible*/);
//...
}
How do I get a compatible pointer?
You'll need to make your serviceCtlHandler
function static
, which means it won't be able to access any object members. This is because RegisterServiceCtrlHandler
is expecting a function pointer which is not tied to an object and will not receive an implied this
pointer.
If you use RegisterServiceCtrlHandlerEx
instead, you can pass a pointer to the object and have the static function call another member function after properly casting the pointer.
精彩评论