I need to know what happening with specified service at runtime to take actions when it state is changed (stopped, deleted, etc.). I tried, but without success, here is what I have:
Delphi-Quellcode:
procedure SvcNotifyCallback(pvParameter: Pointer);
begin
end;
procedure TForm1.FormCreate(Sender: TObject);
var
hSvcMan, hSvc: Cardinal;
Buffer: PSERVICE_NOTIFY;
begin
hSvcMan := OpenSCManager(nil, nil, SC_MANAGER_CONNECT);
GetMem(Buffer, SizeOf(PSERVICE_NOTIFYW));
Buffer^.dwVersion := SERVICE_NOTIFY_STATUS_CHANGE;
Buffer^.pfnNotifyCallback := @SvcNotifyCallback;
Buffer.pContext := Pointer(nil);
hSvc := OpenService(hSvcMan, 'UPS', SC_MANAGER_CONNECT);
NotifyServiceStatusChange(hSvc, SERVICE_NOTIFY_CREATED or SERVICE_NOTIFY_DELETED, Buffer);
end;
This raises external
exception. How to trace service, please?