Link to home
Start Free TrialLog in
Avatar of Subrat (C++ windows/Linux)
Subrat (C++ windows/Linux)Flag for India

asked on

Programming Services in C++

I need a way to change the service parameters like SERVICE_EXIT_CODE value to 2 other than 0.

Plz see the description below.

In command prompt by typing
sc query themes

Displays:
SERVICE_NAME: themes
        TYPE               : 20  WIN32_SHARE_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

I want to change these parameters(ex: WIN32_EXIT_CODE value to -223 or any other value).
FYI: (There is a structure SERVICE_STATUS which takes care of these values.)
I need a program in C++  to achieve it.
Avatar of itsmeandnobodyelse
itsmeandnobodyelse
Flag of Germany image

The service exit code is the return value of an service when terminating. The service can set it to the SERVICE_STATUS structure associated with the service by calling SetServiceStatus passing the handle to the updated structure. If you would write 2 or -223 to the dwCurrentState member of that structure, the Service Control Manager surely would reflect that status.
Avatar of Subrat (C++ windows/Linux)

ASKER

Can u plz send me the code to do that.
Thanks
ASKER CERTIFIED SOLUTION
Avatar of itsmeandnobodyelse
itsmeandnobodyelse
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial