Bonjour, Voila j'ai cree une application que je souhaits mettre en mode Service.
Mais le probleme est que lorsque je vais dans le panneau de configuration
outils d'administration / services
Je vois bien le service que je viens de cree
Ensuite en voulant demarrer le service j'ai un message du style
Impossible de demarrer le service Test
Le service n'a pas repondu assez vite....
Voici le code
[code]
#include <windows.h>
#include <stdio.h>
int main()
{
SC_HANDLE hSCManager = NULL;
SC_HANDLE schService = NULL;
hSCManager = OpenSCManager(
NULL,
SERVICES_ACTIVE_DATABASE,
SC_MANAGER_ALL_ACCESS);
if (hSCManager == NULL) { printf("Erreur OpenSCManager"); }
schService = CreateService(
hSCManager,
"Test",
"Test",
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_DEMAND_START,
SERVICE_ERROR_NORMAL,
"C:\\BoutFroid.exe",
NULL,
NULL,
NULL,
NULL,
NULL);
if (schService == NULL) {
switch (GetLastError())
{
case ERROR_ACCESS_DENIED:
printf("The handle to the SCM database does not have
the SC_MANAGER_CREATE_SERVICE access right.");
break;
case ERROR_CIRCULAR_DEPENDENCY:
printf("A circular service dependency was specified.");
break;
case ERROR_DUPLICATE_SERVICE_NAME:
printf("The
display name already exists in the service control manager database
either as a service name or as another display name.");
break;
case ERROR_INVALID_HANDLE:
printf("The
handle to the specified service control manager database is invalid.");
break;
case ERROR_INVALID_NAME:
printf("The specified service name is invalid.");
break;
case ERROR_INVALID_PARAMETER:
printf("A parameter that was specified is invalid.");
break;
case ERROR_INVALID_SERVICE_ACCOUNT:
printf("The
user account name specified in the lpServiceStartName parameter does
not exist.");
break;
case ERROR_SERVICE_EXISTS:
printf("The specified service already exists in this database.");
break;
default:
printf("Erreur inconnue");
break;
}
}
else { CloseServiceHandle(schService); }
/*
if (!DeleteService(OpenService(
hSCManager,
"Test service",
SC_MANAGER_ALL_ACCESS)))
{
switch (GetLastError())
{
case ERROR_ACCESS_DENIED:
printf("The handle does not have the DELETE access right.");
break;
case ERROR_INVALID_HANDLE:
printf("The specified handle is invalid.");
break;
case ERROR_SERVICE_MARKED_FOR_DELETE:
printf("The specified service has already been marked for deletion.");
break;
default:
printf("Aucune erreur connue");
break;
}
}
*/
return 0;
}
[/code]
Please Help me