IWDFIoRequest::GetFileObject 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 GetFileObject method retrieves a pointer to the IWDFFile interface that is associated with an I/O request.

Syntax

void GetFileObject(
  [out] IWDFFile **ppFileObject
);

Parameters

[out] ppFileObject

A pointer to a buffer that receives a pointer to the IWDFFile interface for the file object. Note that returning NULL is valid.

Return value

None

Remarks

When your driver calls GetFileObject, the framework increments the reference count on the interface. Your driver is responsible for releasing the reference when finished with the interface pointer. To do so, either use a smart pointer that automatically decrements the reference count when the object goes out of context, or call Release on the interface when finished with it.

Examples

The following code example is taken from the WpdMultiTransportDriver sample in the WDK. The example declares a smart pointer to an IWDFFile interface, calls GetFileObject, and then calls RetrieveContext on the file object.

  CComPtr<IWDFFile>   pFileObject;

  ...

  // Get the Context map for this client

  pRequest->GetFileObject(&pFileObject);

  if (pFileObject != NULL)
  {
      hr = pFileObject->RetrieveContext((void**)&pClientContextMap);
      CHECK_HR(hr, "Failed to get Contextmap from WDF File Object");
  }
  

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

IWDFFile

IWDFIoRequest