BOOL ChangeServiceConfig2(SC_HANDLE HandleService, DWORD Nature, LPVOID Informations);
Les caractéristiques sont définies par les informations Informations de nature Nature.
#include <windows.h>
#include <winbase.h>
SC_HANDLE HandleServiceManager;
SC_HANDLE HandleService;
SERVICE_DESCRIPTION Description;
char Commande[256];
...
HandleServiceManager=OpenSCManager(NULL,NULL,SC_MANAGER_CREATE_SERVICE);
if (!HandleServiceManager)
{
...
}
HandleService=CreateService(HandleServiceManager, "MonService", "Libellé du service", (DWORD)(STANDARD_RIGHTS_REQUIRED|SERVICE_CHANGE_CONFIG), SERVICE_WIN32_OWN_PROCESS, SERVICE_DISABLED, SERVICE_ERROR_IGNORE, Commande, NULL, NULL, NULL, NULL, NULL);
if (!HandleService)
{
...
}
Description.lpDescription="Mon commentaire";
if (!ChangeServiceConfig2(HandleService, SERVICE_CONFIG_DESCRIPTION, &Description))
{
...
}
...
if (!DeleteService(HandleService))
{
...
}
CloseServiceHandle(HandleService);
CloseServiceHandle(HandleServiceManager);
...