1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
   | function ServiceCreate(sService,sDisplay,sPath:string):bool; 
var 
 schm, schs : SC_Handle; 
begin 
 result:=false; 
 schm:=OpenSCManager(nil, nil, SC_MANAGER_ALL_ACCESS); 
 if (schm > 0) 
  then begin 
   schs:=CreateService(schm,pchar(sService),pchar(sDisplay),SC_MANAGER_ALL_ACCESS,SERVICE_WIN32_OWN_PROCESS,SERVICE_AUTO_START,SERVICE_ERROR_IGNORE,pchar(sPath),nil,nil,nil,nil,nil);
 
   /* CODE AJOUTÉ/MODIFIÉ */
   if schs > 0 then 
   begin
     result:= (StartService(schs,0,nil) <> 0);
  end 
  else messagebox(0,pchar(inttostr(getlasterror)),0,0); 
  CloseServiceHandle(schs); 
  CloseServiceHandle(schm); 
  end; 
end; | 
Partager