Share via


DeviceSpecificDescriptor Property

The DeviceSpecificDescriptor property gets or sets an array of custom data that is appended to the configuration descriptor.

This property is read/write.

Syntax

HRESULT put_DeviceSpecificDescriptor(
  [in]           SAFEARRAY psaDeviceSpecificData
);

HRESULT get_DeviceSpecificDescriptor(
  [out, retval]  SAFEARRAY ppsaDeviceSpecificData
);

Property Value

A pointer to the new device-specific data for the configuration, in the form of a SAFEARRAY of VARIANT. Each VARIANT must contain an integer between 0 and 255 that uses either the VT_UI1, VT_I2, or VT_I4 data type.

Error Codes

DeviceSpecificDescriptor returns one of the following values:

Name Meaning
S_OK

The operation succeeded.

E_INVALIDARG

The ppsaDeviceSpecificData parameter was not a valid pointer or the psaDeviceSpecificData parameter was NULL

or E_OUTOFMEMORY

The safe array could not be created.

Remarks

The data in this array is appended to the configuration descriptor that is returned to the host in response to a GET_DESCRIPTOR request. The length of this array is added to the wTotalLength field of the descriptor. The data is placed immediately following the standard configuration descriptor portion as defined in section 9.6.3 of the USB 2.0 specification and before the descriptor for the first interface in the configuration.

The following C++ code example shows how to set the DeviceSpecificDescriptor property.

 HRESULT WriteDeviceSpecificDescriptorData
(
 ISoftUSBConfiguration *piConfig,
    BYTE                  *pbData,
 unsigned int cbData
)
{
    HRESULT        hr            = S_OK;
    SAFEARRAY     *psaData       = NULL;
    VARIANT HUGEP *pvarArrayData = NULL;

 psaData = ::SafeArrayCreateVector(VT_VARIANT, 0, cbData);
 if (SUCCEEDED(hr))
    {
 hr = ::SafeArrayAccessData(psaData, &pvarArrayData);
 if (SUCCEEDED(hr))
        {
 for (unsigned int i = 0; i < cbData; i++)
            {
                ::VariantInit(&pVarArrayData[i]);
 pVarArrayData[i].vt = VT_UI1;
 pVarArrayData[i].bVal = pbData[i];
            }
 hr = ::SafeArrayUnaccessData(psaData);
 if (SUCCEEDED(hr))
            {
 hr = piConfig->put_DeviceSpecificDescriptor(psaData);
            }
        }
        (void)::SafeArrayDestroy(psaData);
    }
}

Requirements

Header

SoftUSBif.h

 

 

Send comments about this topic to Microsoft

Build date: 9/21/2010