Group: Service - Library: advapi32
The LockServiceDatabase function requests ownership of the service control manager database lock. Only one process can own the lock at any given time.
Encapsulating access to the Windows Services in a class
SC_LOCK LockServiceDatabase(
SC_HANDLE hSCManager
);
DECLARE INTEGER LockServiceDatabase IN advapi32;
INTEGER hSCManager
hSCManager [in] Handle to the service control manager database.
If the function succeeds, the return value is a lock to the specified service control manager database.
The hSCManager handle is returned by the OpenSCManager function, and must have the SC_MANAGER_LOCK access right.
A call to the StartService function to start a service in a locked database fails. No other service control manager functions are affected by a lock.
See also: UnlockServiceDatabase, OpenSCManager.