views:

24

answers:

2

I could see from MSDN documentations that a new windows service will be stored in the registry HKLM\System\CurrentControlSet\Services

However the services registry key does not hold a value for the "service running status" Can anyone let me know where the service running status will be stored?

+3  A: 

The service running status is not stored in the registry - it's a runtime property which you can query with ControlService() service management function.

sharptooth
I need to know how OS stores and manages the service status. Can you just give a brief about the run time property
Rajakumar S
@Rajakumar S: It does so internally. You use `ControlService()` to retrieve the status.
sharptooth
@sharptooth,I have to write a virtual service system, where I need to manage this in my virtual code. So an API would not help me. Actual service behaviours were needed. It would be great if you show references or any hints.
Rajakumar S
@Rajakumar S Then you have asked the wrong question. Look for how to implement an NT service.
sharptooth
oh okie mate, Thanks for the correction. I explored web to know the service internals. however I couldnot find any. Could you suggest any web reference.
Rajakumar S
@Rajakumar S: Look, search for "create NT service c++" on SO finds this question: http://stackoverflow.com/questions/498460/create-service-on-windows where there's a link to this article http://www.gamedev.net/reference/articles/article1899.asp which looks good. I'm sure there're other questions listed in those search results that contain useful links.
sharptooth
Thanks for your help ..
Rajakumar S
A: 

You can also use sc.exe (C:\WINDOWS\system32\sc.exe)

>sc query fax

SERVICE_NAME: fax
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 1  STOPPED
        WIN32_EXIT_CODE    : 1077  (0x435)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
dmitko