首页 > 其他 > 详细

系统服务

时间:2014-07-29 12:51:26      阅读:386      评论:0      收藏:0      [点我收藏+]
function StopServies(sServiceName: String): boolean; // 停止某个服务;
var
  schService: SC_HANDLE;
  schSCManager: SC_HANDLE;
  ssStatus: TServiceStatus;
begin
  schSCManager := OpenSCManager(nil, nil, SC_MANAGER_ALL_ACCESS);
  schService := OpenService(schSCManager, Pchar(sServiceName), SERVICE_ALL_ACCESS);
  try
    if ControlService(schService, SERVICE_CONTROL_STOP, ssStatus) then
    begin
      Sleep(1000);
      while (QueryServiceStatus(schService, ssStatus)) do
      begin
        Application.ProcessMessages;
        if ssStatus.dwCurrentState = SERVICE_STOP_PENDING then Sleep(1000)
        else break;
      end; // while
      if ssStatus.dwCurrentState = SERVICE_STOPPED then result := True
      else result := False;
    end
    else result := False;
  finally
    CloseServiceHandle(schService);
    CloseServiceHandle(schSCManager);
  end;
end;

系统服务,布布扣,bubuko.com

系统服务

原文:http://blog.csdn.net/gfuchao/article/details/38264827

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!