IWDFDevice::SetPnpState method

The SetPnpState method turns on or off (or sets to the default state) the specified Plug and Play (PnP) property of a device.

Syntax


void SetPnpState(
  [in]  WDF_PNP_STATE State,
  [in]  WDF_TRI_STATE Value
);

Parameters

State [in]

A WDF_PNP_STATE-typed value that identifies the PnP property to set.

Value [in]

A WDF_TRI_STATE-typed value that identifies how to set the PnP property that State specifies. The following table shows the possible values for Value.

ValueMeaning

WdfUseDefault (0)

Set the PnP property to the default state.

WdfFalse (1)

Turn off the PnP property.

WdfTrue (2)

Turn on the PnP property.

 

Return value

None

Remarks

Before the state of the PnP property that SetPnpState set can take effect, the driver must call the IWDFDevice::CommitPnpState method.

Examples

The following code example shows how to indicate that a device failed as the result of a request.


VOID
CUmdfHidDevice::OnCompletion(
    __in IWDFIoRequest* WdfRequest,
    __in IWDFIoTarget* /* WdfTarget */,
    __in IWDFRequestCompletionParams* WdfCompletionParams,
    __in PVOID /* Context */
    )
{
    ULONG_PTR bytesRead;

 if (!SUCCEEDED(WdfCompletionParams->GetCompletionStatus()))
    {
        m_WdfDevice->SetPnpState(WdfPnpStateFailed, WdfTrue);
        m_WdfDevice->CommitPnpState();
        return;
    }

    // Lock the device to prevent files from closing.
    m_WdfDevice->AcquireLock();

    // Retrieve the number of bytes that were read.
    bytesRead = WdfCompletionParams->GetInformation();

    // Process the reports.
    ProcessInputReports((PBYTE) m_ReadMemory->GetDataBuffer(NULL), bytesRead);

    m_WdfDevice->ReleaseLock();

    // Release the request.
    m_InterruptReadRequest = NULL;
    WdfRequest->DeleteWdfObject();

    // Send a new request.
    SendInterruptPipeRead();
}

Requirements

End of support

Unavailable in UMDF 2.0 and later.

Minimum UMDF version

1.5

Header

Wudfddi.h (include Wudfddi.h)

DLL

WUDFx.dll

See also

IWDFDevice
IWDFDevice::CommitPnpState
IWDFDevice::GetPnpState
WDF_PNP_STATE

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft