IUnbufferedFileHandleProvider::OpenUnbufferedFileHandle method (windowsstoragecom.h)

Gets a handle from a random-access byte stream that the StorageFile.OpenAsync method created and registers a callback method that you want to run when the opportunistic lock for the handle is broken.

Syntax

HRESULT OpenUnbufferedFileHandle(
  [in]          IUnbufferedFileHandleOplockCallback *oplockBreakCallback,
  [out, retval] DWORD_PTR                           *fileHandle
);

Parameters

[in] oplockBreakCallback

An interface that contains the implementation of the IUnbufferedFileHandleOplockCallback::OnBrokenCallback method that you want to run when the opportunistic lock for the handle is broken.

[out, retval] fileHandle

The handle from the random-access byte stream.

Return value

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

IUnbufferedFileHandleProvider::OpenUnbufferedFileHandle opens a new handle that is open for GENERIC_READ. IUnbufferedFileHandleProvider::OpenUnbufferedFileHandle does not return the actual handle underlying the stream, or a duplicate of that handle.

Call IUnbufferedFileHandleProvider::CloseUnbufferedFileHandle when you no longer need the handle. The handle is also closed when the opportunistic lock breaks, so your code must process exceptions that occur when the handle is not valid.

Requirements

Requirement Value
Minimum supported client Windows 10 [desktop apps only]
Minimum supported server Windows Server 2016 [desktop apps only]
Target Platform Windows
Header windowsstoragecom.h
DLL Windows.storage.dll

See also

IRandomAccessStream

IUnbufferedFileHandleOplockCallback

IUnbufferedFileHandleOplockCallback::OnBrokenCallback

IUnbufferedFileHandleProvider

IUnbufferedFileHandleProvider::CloseUnbufferedFileHandle