NT Service and COM

André arisen at start.no
Thu Jun 21 15:03:04 EDT 2001


"Duncan Booth" <duncan at NOSPAMrcp.co.uk> wrote in message news:<Xns90C7785FC263Eduncanrcpcouk at 127.0.0.1>...
> Has anyone got a simple example of doing an NT service that also acts as a 
> COM server? It looks as though it shouldn't be too hard, but if someone 
> else has already done it I wouldn't mind copying.
> 

Hi. I found this example in Python Programming on Win32, page 349.
I have not tested it. Am typing in a hurry, beware of tpyos:


import win32serviceutil
import win32service
import win32event

class PythonService(win32serviceutil.ServiceFramework):
    _svc_name_ = "PythonService"
    _scv_display_name_ = "The smallest possible python service."
    def __init__(self, args):
        self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)

    def scvStop(self):
        self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)
        win32event.SetEvent(self.hWaitStop)

    def SvcDoRun(self):
        win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE)

if __name__ == "__main__":
    win32serviceutil.HandleCommandLinw(PythonService)


--
Regards
André Risnes



More information about the Python-list mailing list