> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# IDStorageFactoryX::OpenFile

> IDStorageFactoryX::OpenFile

# IDStorageFactoryX::OpenFile

打开供 DirectStorage 访问的文件。

## Syntax

```cpp theme={null}
HRESULT OpenFile(  
         const WCHAR *path,  
         REFIID riid,  
         void **ppv  
)  
```

### Parameters

*path*   \_In\_z\_\
类型：WCHAR \*

要打开的文件路径。

*riid*\
类型：REFIID

指定 DirectStorage 文件接口，例如 `__uuidof(IDStorageFileX)`。

*ppv*   \_COM\_Outptr\_\
类型：void \*\*

接收代表所打开文件的对象。

### Return value

类型：HRESULT

标准 HRESULT 错误代码。

## Remarks

指定的文件必须存储在受 DirectStorage 支持的 NVM Express (NVMe) 设备上。

当对应 `IDStorageFileX` 对象的最后一个引用被释放时，文件会被隐式关闭。若要显式关闭文件，请调用 [IDStorageFileX::Close](/reference/system/dstorage/interfaces/IDStorageFileX/methods/idstoragefilex_close)。

有关详细信息，请参阅 [DirectStorage 概述](/build/console-features/storage/directstorage/directstorage-overview) 中的“IDStorageFileX”一节。

## Requirements

**头文件：** dstorage\_xs.h

**库：** dstorage\_xs.lib

**受支持的平台：** XBOX Series 主机

## See also

[IDStorageFactoryX](/reference/system/dstorage/interfaces/IDStorageFactoryX/idstoragefactoryx)\
[DStorage](/reference/system/dstorage/dstorage_members)
