Skip to content

Latest commit

 

History

History
66 lines (42 loc) · 1.47 KB

File metadata and controls

66 lines (42 loc) · 1.47 KB

Home

Function name : OpenService

Group: Service - Library: advapi32


The OpenService function opens an existing service.


Code examples:

Encapsulating access to the Windows Services in a class
How to delete a service object

Declaration:

SC_HANDLE OpenService(
  SC_HANDLE hSCManager,
  LPCTSTR lpServiceName,
  DWORD dwDesiredAccess
);
  

FoxPro declaration:

DECLARE INTEGER OpenService IN advapi32;
	INTEGER hSCManager,;
	STRING  lpServiceName,;
	LONG    dwDesiredAccess
  

Parameters:

hSCManager [in] Handle to the service control manager database. The OpenSCManager function returns this handle.

lpServiceName [in] Pointer to a null-terminated string that specifies the name of the service to open.

dwDesiredAccess [in] Access to the service.


Return value:

If the function succeeds, the return value is a handle to the service.


Comments:

Unicode: Implemented as OpenServiceW (Unicode) and OpenServiceA (ANSI).

The returned handle is only valid for the process that called OpenService. It can be closed by calling the CloseServiceHandle function.

See also: StartService, ControlService.