SC_HANDLE WINAPI OpenService(_In_ SC_HANDLE hSCManager,_In_ LPCTSTR lpServiceName,_In_ DWORD dwDesiredAccess);
函數作用:打開一個已經存在的服務
參數:
1. hSCManager:SCM數據庫句柄;
OpenSCManager
3.
dwDesiredAccess:
服務權限
返回值:
成功,返回服務句柄;失敗返回NULL,可以通過GetLastError獲取錯誤碼。
| Return code | Description |
|---|---|
|
The handle does not have access to the service. |
|
The specified handle is invalid. |
|
The specified service name is invalid. |
|
The specified service does not exist. |
說明:
(1)返回的句柄只能用於調用OpenService函數的進程,能夠
CloseServiceHandle
函數關閉。
(2)為了使用
OpenService
,需要
SC_MANAGER_CONNECT。
