Set Windows Service Description in C++

前端 未结 2 1625
夕颜
夕颜 2021-01-01 22:44

I am using CreateService to installs a Windows Service executable however I can\'t seem to find out how to set the description for the service.

Does any

相关标签:
2条回答
  • 2021-01-01 23:24

    Have a look at this MSDN page for an example. You use the ChangeServiceConfig2 method.

    SERVICE_DESCRIPTION sd;
    SC_HANDLE schService;
    SC_HANDLE schSCManager;
    
    // Not shown: Get a handle to the SCM database. 
    // Not shown: Get a handle to the service.
    
    sd.lpDescription = TEXT("Description");
    ChangeServiceConfig2( schService,                 // handle to service
                          SERVICE_CONFIG_DESCRIPTION, // change: description
                          &sd) )                      // new description
    
    0 讨论(0)
  • 2021-01-01 23:26

    Call ChangeServiceConfig2 passing SERVICE_CONFIG_DESCRIPTION as the dwInfoLevel parameter. You will also need a handle to the service, but CreateService gives you one of those.

    SERVICE_DESCRIPTION description = { L"The service description" };
    ChangeServiceConfig2(hService, SERVICE_CONFIG_DESCRIPTION, &description);
    
    0 讨论(0)
提交回复
热议问题