Share via


IWMDMDevice3::DeviceIoControl (deprecated)

banner art

This is preliminary documentation and subject to change.

This topic documents a feature of the Windows Media Device Manager SDK. We recommend that you migrate your application to use the Windows Portable Devices API. For more information, see the Windows Portable Devices SDK.

The DeviceIoControl method sends a Device I/O Control (IOCTL) code to the device. This is a pass-through method; Windows Media Device Manager just forwards the call to the service provider after validating the parameters.

Syntax

HRESULT DeviceIoControl(
  DWORD  dwIoControlCode,
  BYTE*  lpInBuffer,
  DWORD  nInBufferSize,
  BYTE*  lpOutBuffer,
  LPDWORD  pnOutBufferSize
);

Parameters

dwIoControlCode

[in]  Control code to send to the device. When calling this method on an MTP device, use the value IOCTL_MTP_CUSTOM_COMMAND defined in MtpExt.h included with the SDK.

lpInBuffer

[in]  Optional pointer to an input buffer supplied by the caller. It can be NULL if nInBufferSize is zero. When calling this method on an MTP device, you can pass in the MTP_COMMAND_DATA_IN structure.

nInBufferSize

[in]  Size of the input buffer, in bytes. When calling this method on an MTP device, you can use the macro SIZEOF_REQUIRED_COMMAND_DATA_IN to specify the size.

lpOutBuffer

[out]  Optional pointer to the output buffer supplied by the caller. It can be NULL if pnOutBufferSize points to a value of zero. When calling this method on an MTP device, you can pass in the MTP_COMMAND_DATA_OUT structure.

pnOutBufferSize

[in, out]  Size of the output buffer, in bytes. When the call returns, it specifies the number of bytes actually returned. When calling this method on an MTP device, you can use the macro SIZEOF_REQUIRED_COMMAND_DATA_OUT defined in MtpExt.h to specify the size.This parameter cannot be NULL.

Return Values

The method returns an HRESULT. All the interface methods in Windows Media Device Manager can return any of the following classes of error codes:

  • Standard COM error codes
  • Windows error codes converted to HRESULT values
  • Windows Media Device Manager error codes

For an extenstive list of possible error codes, see Error Codes.

Possible values include, but are not limited to, those in the following table. If the method fails with an error, it returns a standard error code.

Return code Description
S_OK The method succeeded.
E_INVALIDARG One or more of the parameters are invalid. This is possible if

a) lpInBuffer is NULL when nInBufferSize is non-zero.

b) lpOutBuffer is NULL when pnOutBufferSize points to a non-zero value.

c) pnOutBufferSize is NULL.

d) Any of the parameters is invalid for the service provider.

WMDM_E_NOTSUPPORTED The service provider or device does not support this method or control code.

Remarks

This method provides a private mode of communication between the application and the service provider. The service provider can then process this IOCTL, optionally modify it, and pass it to the kernel mode driver.

Compared to IWMDMDevice::SendOpaqueCommand, this method better aligns with the DeviceIoControl Windows API because the output buffer is supplied by the caller. Also, unlike IWMDMDevice::SendOpaqueCommand, this method does not involve any MAC check and is more efficient.

This method can be used, for example, to send custom Media Transport Protocol (MTP) commands to an MTP device.

Requirements

Header: Defined in mswmdm.h.

Library: mssachlp.lib

See Also