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

# IGameInputDevice::GetPnpPath

> 入力デバイスのプラグ アンド プレイ デバイス パスを UTF-8 文字列として取得します。

入力デバイスのプラグ アンド プレイ (PnP) デバイス パスを UTF-8 文字列として取得します。

## 構文

```cpp theme={null}
uint32_t GetPnpPath(
    uint32_t bufferByteCount,
    char* buffer
);
```

### パラメーター

*bufferByteCount*   \_In\_\
型: uint32\_t

*buffer* が指すバッファーのサイズ (バイト単位)。必要なサイズをクエリするには 0 を渡します。

*buffer*   \_Out\_writes\_bytes\_opt\_(bufferByteCount)\
型: char\*

null で終わる UTF-8 の PnP パスを受け取るバッファー。必要なサイズをクエリするには `nullptr` を渡します。

### 戻り値

型: uint32\_t

PnP パスを格納するために必要なバッファーのサイズ (バイト単位、null 終端文字を含む)。

## 解説

このメソッドは、*buffer* が `nullptr` ではなく、*bufferByteCount* が必要なサイズ以上の場合にのみ、PnP パスを *buffer* に書き込みます。それ以外の場合、バッファーは変更されません。パスを取得するには、まず *bufferByteCount* に 0、*buffer* に `nullptr` を指定してメソッドを呼び出して必要なサイズを取得し、そのサイズのバッファーを割り当ててから、もう一度メソッドを呼び出します。

デバイスに PnP パスがない場合、必要なサイズは 1 になり、メソッドは空の文字列を書き込みます。

PnP パスを使用すると、他の API を通じて基になるデバイスを参照できます。パスは UTF-8 でエンコードされているため、ワイド文字列を想定する Windows API に渡す前に、UTF-16 に変換してください (たとえば、`CP_UTF8` を指定して `MultiByteToWideChar` を使用します)。

PnP パスは、デバイス オブジェクトの有効期間中は変化しません。

次の例では、デバイスの PnP パスを取得します。

```cpp theme={null}
std::string GetDevicePnpPath(IGameInputDevice* device)
{
    const uint32_t size = device->GetPnpPath(0, nullptr);
    if (size == 0)
    {
        return {};
    }

    std::vector<char> buffer(size);
    device->GetPnpPath(size, buffer.data());

    return std::string(buffer.data());
}
```

GameInput v3 以前では、この情報は [IGameInputDevice::GetDeviceInfo](https://docs.xbox.com/ja-jp/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_getdeviceinfo.md) から返される [GameInputDeviceInfo](https://docs.xbox.com/ja-jp/reference/input/gameinput/deprecated/structs/gameinputdeviceinfo.md) 構造体の `pnpPath` メンバーから取得できました。

## 要件

**ヘッダー:** GameInput.h

**ライブラリ:** gameinput.lib

**サポートされているプラットフォーム:** Windows、XBOX One ファミリー本体、XBOX Series 本体

## 関連項目

[GameInput の概要](https://docs.xbox.com/ja-jp/build/core-features/common/input/overviews/input-overview.md)\
[IGameInputDevice](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)\
[IGameInputDevice::GetDisplayName](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getdisplayname.md)\
[IGameInputDevice::GetContainerId](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontainerid.md)

## バージョン履歴

| バージョン | 変更内容 |
| - | - |
| **v4** | 導入されました。 |


## Related topics

- [IGameInputDevice::GetDisplayName](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getdisplayname.md)
- [IGameInputDevice::GetContainerId](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getcontainerid.md)
- [GameInput のよくある質問](https://docs.xbox.com/ja-jp/build/core-features/common/input/overviews/input-faq.md)
- [IGameInputDevice::GetDeviceFamily](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getdevicefamily.md)
- [IGameInputDevice::GetDeviceId](https://docs.xbox.com/ja-jp/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getdeviceid.md)
