IDXGIResource::GetSharedHandle method (dxgi.h)

[Starting with Direct3D 11.1, we recommend not to use GetSharedHandle anymore to retrieve the handle to a shared resource. Instead, use IDXGIResource1::CreateSharedHandle to get a handle for sharing. To use IDXGIResource1::CreateSharedHandle, you must create the resource as shared and specify that it uses NT handles (that is, you set the D3D11_RESOURCE_MISC_SHARED_NTHANDLE flag). We also recommend that you create shared resources that use NT handles so you can use CloseHandle, DuplicateHandle, and so on on those shared resources.]

Gets the handle to a shared resource.

Syntax

HRESULT GetSharedHandle(
  [out] HANDLE *pSharedHandle
);

Parameters

[out] pSharedHandle

Type: HANDLE*

A pointer to a handle.

Return value

Type: HRESULT

Returns one of the DXGI_ERROR values.

Remarks

GetSharedHandle returns a handle for the resource that you created as shared (that is, you set the D3D11_RESOURCE_MISC_SHARED with or without the D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX flag). You can pass this handle to the ID3D11Device::OpenSharedResource method to give another device access to the shared resource. You can also marshal this handle to another process to share a resource with a device in another process. However, this handle is not an NT handle. Therefore, don't use the handle with CloseHandle, DuplicateHandle, and so on.

The creator of a shared resource must not destroy the resource until all intended entities have opened the resource. The validity of the handle is tied to the lifetime of the underlying video memory. If no resource objects exist on any devices that refer to this resource, the handle is no longer valid. To extend the lifetime of the handle and video memory, you must open the shared resource on a device.

GetSharedHandle can also return handles for resources that were passed into ID3D11Device::OpenSharedResource to open those resources.

GetSharedHandle fails if the resource to which it wants to get a handle is not shared.

Requirements

Requirement Value
Target Platform Windows
Header dxgi.h
Library DXGI.lib

See also

IDXGIResource