Try the following code:
Code:- procedure TTestService.ServiceAfterInstall(Sender: TService);
- var ServiceControlManager, ServiceHandle : SC_Handle;
- ServiceArgVectors: PChar;
- const Access : DWORD = SC_MANAGER_ALL_ACCESS;
- begin
- Try
- ServiceControlManager := OpenSCManager(nil, nil, access);
- If (ServiceControlManager <> 0) // started OK
- Then
- Begin
- ServiceHandle := OpenService(ServiceControlManager, PChar(Self.Name), SERVICE_ALL_ACCESS);
- If ServiceHandle <> 0
- Then
- Begin
- ServiceArgVectors := '';
- If WinSvc.StartService(ServiceHandle, 0, ServiceArgVectors) = False
- Then
- Begin
- ShowMessage('Starting Service Failed.');
- End;
- End;
- End;
- Except
- On e:Exception do
- begin
- showmessage('Problem Encountered When Starting Service.');
- end;
- End;
- end;
Copy Code and remember to add WinSvc to the uses. This will start the service after it has finished installing. Do the install in the same way as described in the article you mentioned.
I have installed the service as mentioned in the article but it is not being listed in the TASKMANAGER and neither it's doing it's dummy task (ie writing file to chttp://bbs.prog365.com/images/sites/smile.gif - any guidlines ? |