> ## 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.

# OpenSharedHandle

> 使用 HANDLE 和 REFIID 打开共享资源、共享堆和共享围栏的句柄。

使用 HANDLE 和 REFIID 打开共享资源、共享堆和共享围栏的句柄。

## 语法

```cpp theme={null}
HRESULT OpenSharedHandle(
    HANDLE NTHandle,
    const IID & riid,
    void  ppvObj
)
```

### 参数

*NTHandle \[in]*\
类型：HANDLE

由对 [ID3D12Device::CreateSharedHandle](/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_createsharedhandle_public) 的调用输出的句柄。

*riid*\
类型：const IID &

以下接口之一的全局唯一标识符 (**GUID**)：

<ul>
  <li>
    [ID3D12Heap](/reference/graphics/d3d12/interfaces/id3d12heap/id3d12heap_public)
  </li>

  <li>
    [ID3D12Resource](/reference/graphics/d3d12_xs/interfaces/ID3D12Resource/id3d12resource_xs)
  </li>

  <li>
    [ID3D12Fence](/reference/graphics/d3d12/interfaces/id3d12fence/id3d12fence_public)
  </li>
</ul>

可以使用 \_\_uuidof() 宏获取接口的 **REFIID** 或 **GUID**。
例如，\_\_uuidof(ID3D12Heap) 将获取资源接口的 **GUID**。

*ppvObj \[out, optional]*\
类型：void \*\*

指向内存块的指针，该内存块接收指向以下接口之一的指针：

<ul>
  <li>
    [ID3D12Heap](/reference/graphics/d3d12/interfaces/id3d12heap/id3d12heap_public)
  </li>

  <li>
    [ID3D12Resource](/reference/graphics/d3d12_xs/interfaces/ID3D12Resource/id3d12resource_xs)
  </li>

  <li>
    [ID3D12Fence](/reference/graphics/d3d12/interfaces/id3d12fence/id3d12fence_public)
  </li>
</ul>

### 返回值

类型：HRESULT

此方法返回 [Direct3D 12 返回代码](https://learn.microsoft.com/en-us/windows/win32/direct3d12/d3d12-graphics-reference-returnvalues) 之一。

## 要求

**头文件：** d3d12\_xs.h 或 d3d12\_x.h\
**库：** d3d12\_xs.lib 或 d3d12\_x.lib\
**支持的平台**：XBOX Series 主机和 XBOX One 系列

## 另请参阅

[ID3D12Device](/reference/graphics/d3d12_x/interfaces/id3d12device/id3d12device)

[多适配器系统](https://learn.microsoft.com/en-us/windows/win32/direct3d12/multi-engine)


## Related topics

- [OpenSharedHandleByName](/zh-CN/reference/graphics/d3d12/interfaces/id3d12device/methods/id3d12device_opensharedhandlebyname_public.md)
- [IGameInputDispatcher::OpenWaitHandle](/zh-CN/reference/input/gameinput/interfaces/IGameInputDispatcher/methods/igameinputdispatcher_openwaithandle.md)
- [SHARED_SHAPE_CONTEXTS](/zh-CN/reference/audio/acphal/structs/shared_shape_contexts.md)
- [PFAuthenticationLoginWithOpenIdConnectAsync](/zh-CN/services/playfab/api-references/c/pfauthentication/functions/pfauthenticationloginwithopenidconnectasync.md)
- [PFAuthenticationReLoginWithOpenIdConnectAsync](/zh-CN/services/playfab/api-references/c/pfauthentication/functions/pfauthenticationreloginwithopenidconnectasync.md)
