On Wed, 11 Dec 2013, Antonio Fortuny wrote:

Hi Folks.

I'am in trouble when attempting to stop a Windows service using the TServiceManager component.
The program runs into a Vista-32 box,
the Lazarus IDE runs in an administrator user console: it has been started as d:...\Lazarus my_project.lpi When I run the program and do a step by step execution all looks good until the StopService line is reachad:
The service name should be the display name, right ?

 SMgr := TServiceManager.Create(nil);
 try
   SMgr.Access := SC_MANAGER_ALL_ACCESS;

You should set refreshonconnect:=true (or something similar).

   SMgr.Connect;

Or call refresh here.

Refresh will re-fetch the list of services from the windows service manager.
It needs this list for the next call:

*SMgr.StopService(SERVICE_NAME, False); *// there are no dependants

Which fails if you do not refresh the list of services.

Michael.

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to