interacting with a Windows Service - Programmer

This is a discussion on interacting with a Windows Service - Programmer ; Hi all, I turned my application in a common user-mode Windows service, which starts at boot time. It works fine, but it seems I can send only predefined messages to my service: install, uninstall, start, stop, pause, continue...That's good, but ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: interacting with a Windows Service

  1. interacting with a Windows Service

    Hi all,

    I turned my application in a common user-mode Windows service, which
    starts at boot time.
    It works fine, but it seems I can send only predefined messages to my
    service: install, uninstall, start, stop, pause, continue...That's
    good, but I need also to send "customized messages" to the service, to
    trigger some special actions in the service.

    Someone knows how to interact with a service by sending user-defined
    commands/signals?

    thank you all!

    matt


  2. Re: interacting with a Windows Service

    Hi,

    You can use the function ControlServiceEx() to send controls,
    however, if you want a better approach to communicate with the
    service process in an efficient way, you should use named pipes:

    You can communicate with the service locally and remotely.
    You can have secured access methods with impersonation.
    You can send and receive large messages.

    Use the following APIs to create/handle/manage the named pipe:

    CreateNamedPipe()
    SetNamedPipeHandleState()
    ConnectNamedPipe()
    CreateFile()
    ReadFile()
    WriteFile()
    CloseHandle()
    ImpersonateNamedPipeClient()
    RevertToSelf()

    http://msdn.microsoft.com/library/de...lserviceex.asp

    http://msdn.microsoft.com/library/de...enamedpipe.asp

    http://msdn.microsoft.com/library/de...andlestate.asp

    http://msdn.microsoft.com/library/de...tnamedpipe.asp

    http://msdn.microsoft.com/library/de...createfile.asp

    http://msdn.microsoft.com/library/de...s/readfile.asp

    http://msdn.microsoft.com/library/de.../writefile.asp

    http://msdn.microsoft.com/library/de...losehandle.asp

    http://msdn.microsoft.com/library/de...pipeclient.asp

    http://msdn.microsoft.com/library/de...verttoself.asp

    Hope these suggestions helps,

    Kellie.


+ Reply to Thread