CreateRandomAccessStreamOnFile function (shcore.h)

Creates a Windows Runtime random access stream for a file.

Syntax

HRESULT CreateRandomAccessStreamOnFile(
  [in]  PCWSTR filePath,
  [in]  DWORD  accessMode,
  [in]  REFIID riid,
  [out] void   **ppv
);

Parameters

[in] filePath

The fully qualified path of the file to encapsulate.

[in] accessMode

An AccessMode value that specifies the behavior of the RandomAccessStream that encapsulates the file.

[in] riid

A reference to the IID of the interface to retrieve through ppv, typically IID_RandomAccessStream.

[out] ppv

When this method returns successfully, contains the interface pointer requested in riid, typically the IRandomAccessStream that encapsulates the file.

Return value

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

Remarks

Use the CreateRandomAccessStreamOnFile function to create a RandomAccessStream that encapsulates a file.

We recommend that you use the IID_PPV_ARGS macro, defined in Objbase.h, to package the riid and ppv parameters. This macro provides the correct IID based on the interface pointed to by the value in ppv, which eliminates the possibility of a coding error in riid that could lead to unexpected results.

Requirements

Requirement Value
Minimum supported client Windows 8 [desktop apps | UWP apps]
Minimum supported server Windows Server 2012 [desktop apps | UWP apps]
Target Platform Windows
Header shcore.h
Library Shcore.lib
DLL Shcore.dll

See also

CreateRandomAccessStreamOverStream

CreateStreamOverRandomAccessStream

RandomAccessStream