hSCManager,hService:SC_HANDLE;
returnstatus:TServiceStatus;
.
.
.
.
.
procedure CloseService(ServerName:String);
begin
hService:=OpenService(hscmanager,Pchar(ServerName),SERVICE_ALL_ACCESS);
if hService>=0 then
begin
QueryServiceStatus(hService,returnstatus);
if returnstatus.dwCurrentState=SERVICE_RUNNING then
ControlService(hService,SERVICE_CONTROL_STOP,returnstatus);
CloseServiceHandle(hService);//关闭该Service
end;//if hService>=0 then
end;
.
.
.
.
.请问我这个函数有问题吗?怎么关闭不了服务啊!
returnstatus:TServiceStatus;
.
.
.
.
.
procedure CloseService(ServerName:String);
begin
hService:=OpenService(hscmanager,Pchar(ServerName),SERVICE_ALL_ACCESS);
if hService>=0 then
begin
QueryServiceStatus(hService,returnstatus);
if returnstatus.dwCurrentState=SERVICE_RUNNING then
ControlService(hService,SERVICE_CONTROL_STOP,returnstatus);
CloseServiceHandle(hService);//关闭该Service
end;//if hService>=0 then
end;
.
.
.
.
.请问我这个函数有问题吗?怎么关闭不了服务啊!
解决方案 »
- 在delphi中如何使用MediaPlayer循环播放Wav文件
- 请教数据库多表(3表)联合操作的问题:数据量大会引起程序假死!该如何解决!
- 如何用delphi6实现自动删除某文本文件中的部分内容?--具体请看内容
- 前天去大面试,那公司要我写一个技术文档给他,但我没写过,不知道怎么写,哪位大虾知道的能否过来说一下!在线等!!!
- 如何把标注文字加在条形码的下面??
- 使用DBGrid是否可以自行增加一列?
- 利用database desktop建立表,怎样从一个记录进入另一个记录的编辑状态,谢谢!在线等待!
- 请问 I/O 32 是什么错误?
- DElphi4中的汇编问题,50分,答案2句话,快来拿分!!
- 关于动态报表的问题
- 怎样在使用了数据集的LOCATE定位后,设置dbgrid中定位的行的颜色?
- 百分相送!讨论一下关于网络监控问题
还是,要用一些WINDOWS自带的函数什么的,最好看看它的使用环境,条件。
LPSERVICE_STATUS lpServiceStatus // address of status structure
);Value Meaning
SERVICE_STOPPED The service is not running.
SERVICE_START_PENDING The service is starting.
SERVICE_STOP_PENDING The service is stopping.
SERVICE_RUNNING The service is running.
SERVICE_CONTINUE_PENDING The service continue is pending.
SERVICE_PAUSE_PENDING The service pause is pending.
SERVICE_PAUSED The service is paused.