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

# 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](https://docs.xbox.com/zh-CN/reference/system/dstorage/interfaces/IDStorageFileX/methods/idstoragefilex_close.md)。

有关详细信息，请参阅 [DirectStorage 概述](https://docs.xbox.com/zh-CN/build/console-features/storage/directstorage/directstorage-overview.md) 中的“IDStorageFileX”一节。

## Requirements

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

**库：** dstorage\_xs.lib

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

## See also

[IDStorageFactoryX](https://docs.xbox.com/zh-CN/reference/system/dstorage/interfaces/IDStorageFactoryX/idstoragefactoryx.md)\
[DStorage](https://docs.xbox.com/zh-CN/reference/system/dstorage/dstorage_members.md)


## Related topics

- [IDStorageFileX::Close](https://docs.xbox.com/zh-CN/reference/system/dstorage/interfaces/IDStorageFileX/methods/idstoragefilex_close.md)
- [IDStorageFileX（接口内容）](https://docs.xbox.com/zh-CN/reference/system/dstorage/interfaces/IDStorageFileX/idstoragefilex.md)
- [GetHandle](https://docs.xbox.com/zh-CN/reference/system/dstorage/interfaces/IDStorageFileX/methods/idstoragefilex_gethandle.md)
- [IDStorageFactoryX（接口内容）](https://docs.xbox.com/zh-CN/reference/system/dstorage/interfaces/IDStorageFactoryX/idstoragefactoryx.md)
- [DirectStorage 概述](https://docs.xbox.com/zh-CN/build/console-features/storage/directstorage/directstorage-overview.md)
