delphi programming forums mysql charset mget recursive synonimos
free ventrilo servers hosting cs javascript delay python find in list
Back Forum New
abstract:

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 ?


hi,
I have tried to create a sample service by reading this article
http://www.devarticles.com/c/a/Delphi-Kylix/Creating-a-Windows-Service-in-Delphi/
but now i don't know how to test it. 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 c - any guidlines ?

TOP

Try the following code:
Code:
  1. procedure TTestService.ServiceAfterInstall(Sender: TService);
  2. var ServiceControlManager, ServiceHandle : SC_Handle;
  3.     ServiceArgVectors: PChar;
  4. const Access : DWORD = SC_MANAGER_ALL_ACCESS;
  5. begin
  6.   Try
  7.     ServiceControlManager := OpenSCManager(nil, nil, access);
  8.     If (ServiceControlManager <> 0)   // started OK
  9.       Then
  10.         Begin
  11.           ServiceHandle := OpenService(ServiceControlManager, PChar(Self.Name), SERVICE_ALL_ACCESS);
  12.           If ServiceHandle <> 0
  13.             Then
  14.               Begin
  15.                 ServiceArgVectors := '';
  16.                 If WinSvc.StartService(ServiceHandle, 0, ServiceArgVectors) = False
  17.                   Then
  18.                     Begin
  19.                       ShowMessage('Starting Service Failed.');
  20.                     End;
  21.               End;
  22.         End;
  23.   Except
  24.     On e:Exception do
  25.       begin
  26.         showmessage('Problem Encountered When Starting Service.');
  27.       end;
  28.   End;
  29. 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 ?

TOP

Back Forum