[python-win32] RegisterServiceCtrlHandler(Ex) and Handler(Ex)
Mark Hammond
mhammond at skippinet.com.au
Tue Feb 5 12:24:25 CET 2008
> While trying to use RegisterServiceCtrlHandler function, it appears
> that
> this function acts like RegisterServiceCtrlHandlerEx if it is run on
> W2000 or higher.
Yes - this is because it calls RegisterServiceCtrlHandlerEx on those
platforms.
> According to msdn, a HandlerEx function has to be used to get
> callbacks.
> This function should take 4 arguments :
> DWORD WINAPI HandlerEx(
> __in DWORD dwControl,
> __in DWORD dwEventType,
> __in LPVOID lpEventData,
> __in LPVOID lpContext
> );
>
> But in fact it gets only one.
> I've modified win32serviceutil to verify it :
> def ServiceCtrlHandler(self, control) => def ServiceCtrlHandler(self,
> control, *args)
>
> and :
> def SvcOther(self, control, *args):
>
> *args still is an empty tuple (). I only get "dwControl", why don't I
> get "dwEventType", "lpEventData" and "lpContext" (this last one is user
> defined so it can be empty, but not the other two) ?
It is because I took a bit of a shortcut, and when moving to
RegisterServiceCtrlHandlerEx() I didn't work to allow for an alternative
python callback that takes the additional args (and supplying them, as in
the '* args' in your example, would break existing services). I'd be happy
to add this though - contact me offline for the best way to arrange for this
(and lpContext is used by the implementation, so if you have a specific
use-case for this param, I'd like to know about that too)
Cheers,
Mark
More information about the python-win32
mailing list