IWDFDevice::SetPnpState method (wudfddi.h)

[Warning: UMDF 2 is the latest version of UMDF and supersedes UMDF 1. All new UMDF drivers should be written using UMDF 2. No new features are being added to UMDF 1 and there is limited support for UMDF 1 on newer versions of Windows 10. Universal Windows drivers must use UMDF 2. For more info, see Getting Started with UMDF.]

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

[in] State

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

[in] Value

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.

Value Meaning
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

Requirement Value
End of support Unavailable in UMDF 2.0 and later.
Target Platform Desktop
Minimum UMDF version 1.5
Header wudfddi.h (include Wudfddi.h)
DLL WUDFx.dll

See also

IWDFDevice

IWDFDevice::CommitPnpState

IWDFDevice::GetPnpState

WDF_PNP_STATE