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

# GetDevice

> このインターフェイスを作成したデバイスへのポインターを取得します。

このインターフェイスを作成したデバイスへのポインターを取得します。

## 構文

```cpp theme={null}
void GetDevice(
    const IID & riid,
    void** ppvDevice
)
```

### パラメーター

*riid*\
型: const IID &

デバイス インターフェイスのグローバル一意識別子 (**GUID**)。
デバイスに対するインターフェイスの **REFIID** または **GUID** は、\_\_uuidof() マクロを使用して取得できます。
たとえば、\_\_uuidof([ID3D12Device](/reference/graphics/d3d12_x/interfaces/id3d12device/id3d12device)) はデバイスに対するインターフェイスの **GUID** を取得します。

*ppvDevice \[out, optional]*\
型: **void**\*\*

デバイスの [ID3D12Device](/reference/graphics/d3d12_x/interfaces/id3d12device/id3d12device) インターフェイスへのポインターを受け取るメモリ ブロックへのポインター。

### 戻り値

型: void

このメソッドは [Direct3D 12 の戻り値コード](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/d3d12-graphics-reference-returnvalues) のいずれかを返します。

## 解説

返されたインターフェイスは参照カウントが 1 つ増加するため、解放される前に返されたポインターに対して必ず ::release() を呼び出してください。そうしないとメモリ リークが発生します。

#### 使用例

[D3D12Multithreading](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/working-samples) サンプルでは、**ID3D12DeviceChild::GetDevice** を次のように使用します。

```cpp theme={null}
// Returns required size of a buffer to be used for data upload
inline UINT64 GetRequiredIntermediateSize(
_In_ ID3D12Resource* pDestinationResource,
_In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource,
_In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources)
{
D3D12_RESOURCE_DESC Desc = pDestinationResource->GetDesc();
UINT64 RequiredSize = 0;

ID3D12Device* pDevice;
pDestinationResource->GetDevice(__uuidof(*pDevice), reinterpret_cast<void**>(&pDevice));
pDevice->GetCopyableFootprints(&Desc, FirstSubresource, NumSubresources, 0, nullptr, nullptr, nullptr, &RequiredSize);
pDevice->Release();

return RequiredSize;
}

```

[D3D12 リファレンスのサンプル コード](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/notes-on-example-code) を参照してください。

<div class="code" />

## 要件

**ヘッダー:** d3d12\_xs.h または d3d12\_x.h\
**ライブラリ:** d3d12\_xs.lib または d3d12\_x.lib\
**サポートされるプラットフォーム**: XBOX Series 本体および XBOX One ファミリ

## 関連項目

[ID3D12DeviceChild](/reference/graphics/d3d12/interfaces/id3d12devicechild/id3d12devicechild_public)


## Related topics

- [IGameInputReading::GetDevice](/ja-jp/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getdevice.md)
- [PartyNetwork::GetDevices](/ja-jp/services/playfab/multiplayer/networking/reference/classes/PartyNetwork/methods/partynetwork_getdevices.md)
- [PartyEndpoint::GetDevice](/ja-jp/services/playfab/multiplayer/networking/reference/classes/PartyEndpoint/methods/partyendpoint_getdevice.md)
- [IGameInputForceFeedbackEffect::GetDevice](/ja-jp/reference/input/gameinput/interfaces/igameinputforcefeedbackeffect/methods/igameinputforcefeedbackeffect_getdevice.md)
- [PartyChatControl::GetDevice](/ja-jp/services/playfab/multiplayer/networking/reference/classes/PartyChatControl/methods/partychatcontrol_getdevice.md)
