I use a routine that can start and stop services via Delphi but I also need to be able to disable them, is it possible?
相关问题
- Is there a Delphi 5 component that can handle .png
- Is there a way to install Delphi 2010 on Windows 2
- Is TWebBrowser dependant on IE version?
- iOS objective-c object: When to use release and wh
- DBGrid - How to set an individual background color
相关文章
- Service层和Dao层一定要对应吗?
- k8s 访问Pod 时好时坏
- Best way to implement MVVM bindings (View <-> V
- Async task does not work properly (doInBackground
- Windows EventLog: How fast are operations with it?
- How to force Delphi compiler to display all hints
- Coloring cell background on firemonkey stringgrid
- HelpInsight documentation in Delphi 2007
Open the service with
OpenService
, and then disable it by passingService_Disabled
as thedwStartType
parameter forChangeServiceConfig
. Specify a null pointer orService_No_Change
for the rest of the parameters since you're not interested in changing them.This is what i use
Which lets you write 'nice' delphi code ;)
the DisableService section hasnt been written, but all that is needed is
You can use file JclSvcCtrl.pas from JEDI Components Library (JCL). I have written a pseudo example that you could use. However, be aware that I didn't test it. But in this way it should work (error checks omitted):
Besides using the previous methods, if you need more control you can use WMI.
With Win32_Service class have access to all information of the services installed on the machine and you can has access to methods: Start, Stop, Pause, Resume, Interrogate, Create, Delete, Change, ChangeStartMode...
Here (Web / SourceForge)you can find a set of components to work with WMI (GLibWMI components Library); There are one called CServiceInfo thah give you all information and some methods of this class.
In addition with the package tere are some demos; One is called (ServiceControl) and implement all methods.
alt text http://img341.imageshack.us/img341/8505/imagen336.png
All the package are source included. See the code it can be usefull for you.
Regards.