function ServiceStop(const ServiceName: string): Boolean;<br>{<br> 停止服务<br>}<br>var<br> SCM, SCH: SC_Handle;<br> ServiceStatus: TServiceStatus;<br>begin<br> Result := False;<br> SCM := OpenSCManager(computername, nil, SC_MANAGER_ALL_ACCESS);<br> if SCM <> 0 then<br> begin<br> SCH := OpenService(SCM, PChar(ServiceName), SERVICE_ALL_ACCESS);<br> if SCH <> 0 then<br> begin<br> Result := ControlService(SCH, SERVICE_CONTROL_STOP, ServiceStatus);<br> CloseServiceHandle(SCH);<br> end;<br> CloseServiceHandle(SCM);<br> end;<br>end;