QueryServiceLockStatus

  BOOL QueryServiceLockStatus(hSCManager, lpLockStatus, cbBufSize, pcbBytesNeeded)    
  SC_HANDLE hSCManager;    
  LPQUERY_SERVICE_LOCK_STATUS lpLockStatus;    
  DWORD cbBufSize;    
  LPDWORD pcbBytesNeeded;    

The QueryServiceLockStatus function examines the lock status on a specified database.

Parameters

hSCManager

Handle obtained from a previous OpenSCManager call.

lpLockStatus

A pointer to a buffer to receive a QUERY_SERVICE_LOCK_STATUS information structure.

cbBufSize

Size of the buffer in bytes pointed to by lpLockStatus.

pcbBytesNeeded

A pointer to a variable to receive the number of bytes needed to read the status information.

Return Value

Returns TRUE if the lock status information is successfully written into the supplied output buffer. If the return value is FALSE, an error has occurred. Use GetLastError to determine the cause of the failure.

Errors Value Meaning
  ERROR_ACCESS_DENIED  
    The specified handle was not opened with SC_MANAGER_QUERY_LOCK_STATUS access.
  ERROR_INVALID_HANDLE  
    The specified handle is invalid.
  ERROR_INSUFFICIENT_BUFFER  
    The supplied output buffer is too small for the QUERY_SERVICE_LOCK_STATUS information structure. Nothing is written to the supplied output buffer.