简体   繁体   中英

How to run 64bit c++ console exe as a service in windwos service

i am trying to run a c++ console app as a service in windows but i have build the exe in 64 bit config in VS2019. I can able to install and remove the service but if i start the service its shows following status in CMD

 TYPE: 10 WIN32_OWN_PROCESS
    STATE              : 2  START_PENDING
                            (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
    WIN32_EXIT_CODE    : 0  (0x0)
    SERVICE_EXIT_CODE  : 0  (0x0)
    CHECKPOINT         : 0x1
    WAIT_HINT          : 0x258
    PID                : 23248

is it possible to change the Service type to WINX64 process or is there any sample i have used git hub SampleService code to create a service app out of console c++ app.Following is the service creation called in my sample

        hService = CreateService(
        hManager,                   // SCManager database
        _T("SampleService"),                 // name of service
        _T("SampleService app"), // name to display
        SERVICE_ALL_ACCESS,         // desired access
        SERVICE_WIN32_OWN_PROCESS | // service type
        SERVICE_INTERACTIVE_PROCESS,
        SERVICE_AUTO_START,         // start type
        SERVICE_ERROR_NORMAL,       // error control type
        Target,                     // service's binary
        NULL,                       // no load ordering group
        NULL,                       // no tag identifier
        NULL,                       // dependencies
        NULL,                       // LocalSystem account
        NULL);                      // no password

i am trying to run as a syswow64 kind of app

WIN32_OWN_PROCESS doesn't mean 32 bit. You can check the service bit through task manager->Details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM