Service install in XP

From: PrMon (nospam_at_nospam.com)
Date: 10/30/03


Date: Thu, 30 Oct 2003 16:14:11 +0200

I'm trying to install service programatically in WinXP.. So i wrote this
code, but it's not working.. What is the problem with this code ?

Regards,

procedure TForm1.Button1Click(Sender: TObject);
var
  SCMHandle: THandle;
begin
  SCMHandle := OpenSCManager('', '', SC_MANAGER_CREATE_SERVICE);

    CreateService(SCMHandle,
                  PChar('MyGuard'),
                  PChar('MyGuard'),
                  SERVICE_ALL_ACCESS,
                  SERVICE_WIN32_OWN_PROCESS,
                  SERVICE_AUTO_START,
                  SERVICE_ERROR_NORMAL,
                  PChar( 'C:\Guard.exe'), '', nil, '', '', '');

    CloseServiceHandle(SCMHandle);
end;


Quantcast