> ## 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 存取。

## 語法

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

### 參數

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

要開啟之檔案的路徑。

*riid*\
類型：REFIID

指定 DirectStorage 檔案介面，例如 `__uuidof(IDStorageFileX)`。

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

接收代表已開啟檔案的物件。

### 傳回值

類型：HRESULT

標準 HRESULT 錯誤碼。

## 備註

指定的檔案必須儲存在 DirectStorage 支援的 NVM Express (NVMe) 裝置上。

當對應 `IDStorageFileX` 物件的最後一個參考被釋放時，檔案會隱含地關閉。若要明確關閉檔案，請呼叫 [IDStorageFileX::Close](/zh-TW/reference/system/dstorage/interfaces/IDStorageFileX/methods/idstoragefilex_close)。

如需詳細資訊，請參閱 [DirectStorage 概觀](/zh-TW/build/console-features/storage/directstorage/directstorage-overview)中的「IDStorageFileX」一節。

## 需求

**標頭：** dstorage\_xs.h

**程式庫：** dstorage\_xs.lib

**支援的平台：** XBOX Series 主機

## 另請參閱

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


## Related topics

- [IDStorageFactoryX::OpenFile](/ja-jp/reference/system/dstorage/interfaces/IDStorageFactoryX/methods/idstoragefactoryx_openfile.md)
- [IDStorageFileX](/ko/reference/system/dstorage/interfaces/IDStorageFileX/idstoragefilex.md)
