O'Reilly logo

Python Programming On Win32 by Mark Hammond, Andy Robinson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Connecting to a Service

Once you have a handle to the SCM, open a specific service using the function win32service.OpenService() , which has the following signature.

handle = win32service.OpenService(schandle, serviceName, desiredAccess)
schandle

A handle to the SCM, as obtained from win32service.OpenSCManager().

serviceName

The name of the service to open.

desiredAccess

A bitmask of flags defining the desired access. win32service.SERVICE_ALL_ACCESS provides all access.

Now that you’re connected to the SCM, you can obtain a handle to the messenger service with the following code:

>>> hs=win32service.OpenService(hscm, "Messenger", 
...                             win32service.SERVICE_ALL_ACCESS)
>>> hs
1375960
>>>

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required