Share via


ServiceIoControl

This function sends a control code directly to a specified device driver causing the corresponding device to perform the specified operation.

BOOL ServiceIoControl(
  HANDLE hService,
  DWORD dwIoControlCode,
  LPVOID lpInBuf,
  DWORD nInBufSize,
  LPVOID lpOutBuf,
  DWORD nOutBufSize,
  LPDWORD lpBytesReturned,
  LPOVERLAPPED lpOverlapped
);

Parameters

  • hService
    [in] Handle to the service that is to perform the specified operation. The GetServiceHandle function should be called to obtain an unknown service handle.
  • dwIoControlCode
    [in] Specifies the control code for the operation. This value indicates the specific operation to be performed and the type of device on which the operation is to be performed. No values are defined for this parameter; however, the writer of a custom device driver may define IOCTL_XXX control codes per the CTL_CODE macro. These control codes can then be advertised and an application can use them along with DeviceIoControl to perform driver-specific functions.
  • lpInBuf
    [in] Pointer to a buffer that contains the data required to perform the operation. This parameter can be set to NULL if the dwIoControlCode parameter specifies an operation that does not require input data.
  • nInBufSize
    [in] Size, in bytes, of the buffer pointed to by lpInBuffer.
  • lpOutBuf
    [out] Pointer to a buffer that receives the operation's output data. This parameter can be set to NULL if the dwIoControlCode parameter specifies an operation that does not produce output data.
  • nOutBufSize
    [in] Size, in bytes, of the buffer pointed to by lpOutBuffer.
  • lpBytesReturned
    [out] Pointer to a variable that receives the size, in bytes, of the data stored into the buffer pointed to by lpOutBuffer. Even when an operation produces no output data and lpOutBuffer can be set to NULL, the ServiceIoControl function makes use of the variable pointed to by lpBytesReturned.
  • lpOverlapped
    [in] This parameter is ignored and set to NULL.

Return Values

A nonzero value indicates success. A value of zero indicates failure. To get extended error information, call GetLastError.

Remarks

ServiceIoControl can only be used for handles obtained through ActivateService, RegisterService, EnumServices, or GetServiceHandle. If a service is opened using CreateFile, DeviceIoControl must be used to pass IO control codes to the underlying service.

Requirements

OS Versions: Windows CE .NET 4.0 and later.
Header: Service.h.
Link Library: Coredll.lib.

See Also

ActivateService | RegisterService | GetServiceHandle | EnumServices | CreateFile | DeviceIoControl | Services.exe

 Last updated on Saturday, April 10, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.