Madmarlin
asked on
Service Status Checking....
Hi,
I'm trying to check the current status of a service.
I've used this sample code from a previous question logged on this site but when I change the service name from 'Alerter' to for example 'ClipBook' the returning value is given as an error (The Handle Is Invalid)
Any ideas as to why..
procedure TForm1.Button2Click(Sender
var SC : integer;
SHwnd : integer;
ST : _Service_Status;
begin
SC:=OpenSCManager(nil,'Ser
SHwnd:=OpenService(SC,'Cli
if not QueryServiceStatus(SHwnd,S
then Listbox1.Items.Add('Error:
else begin
with listbox1.items do
case st.dwCurrentState of
SERVICE_START_PENDING : Add('service start pending');
SERVICE_STOPPED : Add('service stopped');
SERVICE_STOP_PENDING : Add('service stop pending');
SERVICE_RUNNING : Add('service started');
SERVICE_CONTINUE_PENDING : Add('service continue pending');
SERVICE_PAUSE_PENDING : Add('service pause pending');
SERVICE_PAUSED : Add('service paused');
end;
end;
end;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks..
Madmarlin