Restarting after being paused
SERVICE_PAUSE_PENDING=6; // Pausing
SERVICE_PAUSED=7; //Paused
type
TForm1 = class(TForm)
cs: TClientSocket;
Button1: TButton;
Timer1: TTimer;
Label1: TLabel;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function SQLSCMGetLocalServiceStateA(lpszSvc: PChar;dwErr:PDWORD): Integer;cdecl;external ''w95scm.dll'';
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
cs.Open;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
try
cs.Active := true;
finally
if cs.Active then
Label1.Caption := ''Runnig''
else
Label1.Caption := ''Not Runnig'';
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
r,e: DWORD;
begin
r := SQLSCMGetLocalServiceStateA(''MSSQLServer'',@e);
case r of
SERVICE_STOPPED:
ShowMessage(''Stoped'');
SERVICE_START_PENDING:
ShowMessage(''Starting'');
SERVICE_STOP_PENDING:
ShowMessage(''Stopping'');
SERVICE_RUNNING:
ShowMessage(''Running'');
SERVICE_CONTINUE_PENDING:
ShowMessage(''Restarting'');
SERVICE_PAUSE_PENDING:
ShowMessage(''Pausing'');
SERVICE_PAUSED:
ShowMessage(''Paused'');
end;
end;
end.