Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function sends a control code directly to a specified device driver causing the corresponding device to perform the specified operation. This function is deprecated. To obtain a handle to a service, call CreateFile. To control the service, call DeviceIoControlwith the same parameters you would set for ServiceIoControl.

Syntax

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 GetServiceHandlefunction 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_XXXcontrol codes per the CTL_CODE macro. These control codes can then be advertised and an application can use them along with DeviceIoControlto 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 dwIoControlCodeparameter 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 dwIoControlCodeparameter 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 lpOutBuffercan be set to NULL, the ServiceIoControlfunction makes use of the variable pointed to by lpBytesReturned.

lpOverlapped

[in] This parameter is ignored and set to NULL.

Return Value

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

Remarks

ServiceIoControlis deprecated. To obtain a handle to a service, call CreateFile. To control the service, call DeviceIoControlwith the same parameters you would set for ServiceIoControl.

Requirements

Header service.h
Library coredll.lib
Windows Embedded CE Windows CE .NET 4.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also