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

# WdLaunchRemoteGame

> WdLaunchRemoteGame

# WdLaunchRemoteGame

リモート デバイス上でゲームを起動します。

## 構文

```cpp theme={null}
HRESULT WdLaunchRemoteGame(  
         _In_z_ const char* remoteDevice,  
         _In_z_ const char* remotePath,  
         _In_opt_z_ const char* args,  
         _In_opt_ const WdLaunchOptions* launchOptions,  
         _Out_opt_ uint32_t* processId,  
         _Out_opt_ uint32_t* threadId  
);  
```

### パラメーター

`_In_z_ remoteDevice`\
Type: **const char\***

リモート デバイスのホスト名または IP アドレス (例: `"192.168.1.100"` または `"MyDevKit"`)。

`_In_z_ remotePath`\
Type: **const char\***

リモート デバイス上のゲーム実行可能ファイルへのパス。絶対パス (例: `"D:\\Games\\MyGame\\game.exe"`)、または共通ルートに対して解決される相対パス (例: `"MyGame\\game.exe"`) を指定できます。

`_In_opt_z_ args`\
Type: **const char\***

省略可能。ゲーム実行可能ファイルに渡すコマンド ライン引数 (例: `"-windowed -debug"`)。引数が不要な場合は `nullptr` を渡します。

`_In_opt_ launchOptions`\
Type: **[WdLaunchOptions](/reference/remoting/structs/wdlaunchoptions)\***

省略可能。起動モードと共通ルート エイリアスを指定します。既定の設定 (`Immediate` 起動、既定の共通ルート) を使用するには `nullptr` を渡します。

`_Out_opt_ processId`\
Type: **uint32\_t\***

省略可能。起動されたゲームのプロセス ID を受け取ります。プロセス ID が不要な場合は `nullptr` を渡します。

`_Out_opt_ threadId`\
Type: **uint32\_t\***

省略可能。起動されたゲームのメイン スレッドのスレッド ID を受け取ります。スレッド ID が不要な場合は `nullptr` を渡します。

### 戻り値

Type: **HRESULT**

成功した場合は `S_OK` を返します。それ以外の場合はエラー コードを返します。

#### エラー コード

| コード                     | 値          | 説明                          | 根本原因                                                                                     | トラブルシューティング                                                                                                        |
| ----------------------- | ---------- | --------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| E\_GAMEFILEPATHNOTEXIST | 0x8C114010 | ゲーム ファイル パスが存在しません。         | 指定されたゲーム実行可能ファイルまたはパッケージ パスが、リモート マシン上で無効またはアクセスできません。                                   | パスがリモート デバイス上に存在することを確認してください。コピー操作が成功したことを確認してください                                                                |
| E\_CONNECTIONERROR      | 0x8C114014 | 接続エラー。                      | IP アドレスの有効性やリモート マシン名の解決とは無関係の、ネットワーク接続の確立時の一般的な失敗 (トランスポート レベルの失敗)。                     | ネットワーク接続、ファイアウォールの規則、リモート マシン上のサービスの可用性を確認してください。デバイス間の可視性を確認してください。デバイスは互いに ping できる必要があります。ログを有効にして接続を再試行してください。 |
| E\_NAMERESOLUTIONFAILED | 0x8C114012 | リモート マシン名を解決できませんでした。       | DNS またはローカル名前解決を介してホスト名を解決できません。                                                         | ホスト名のスペル、DNS 構成、ネットワーク接続を確認してください。IP アドレスを使用して名前解決の問題を切り分けてください。                                                   |
| E\_INVALIDADDRESS       | 0x8C114013 | 無効なアドレス。                    | 正しくない、不正な形式の、またはサポートされていないネットワーク アドレスが指定されました (例: 不正な IP 形式、間違った IP、またはサポートされていないプロトコル)。 | 正しい IP アドレスを確認してください。アドレスの形式を修正し、IPv4 プロトコルを使用していることを確認してください                                                      |
| E\_CLIENTNOTAUTHORIZED  | 0x8C114008 | デバイスがクライアントを拒否しました。         | クライアントがデバイスの信頼できるクライアントのリストにありません。ペアリング プロセスを完了する前に接続試行が開始されました                          | ピン ペアリング プロセスを正常に完了してください。接続要求を再度実行してください                                                                          |
| E\_SERVERNOTAUTHORIZED  | 0x8C114009 | クライアントがデバイスを拒否しました。         | ターゲット デバイスがクライアントの信頼できるエンドポイントのリストにありません。ペアリング プロセスを完了する前に接続試行が開始されました                   | ピン ペアリング プロセスを正常に完了してください。接続要求を再度実行してください                                                                          |
| E\_SERVERTOOOLD         | 0x8C114011 | サーバー バージョンがこのクライアントには古すぎます。 | クライアント側の API バージョンがリモート デバイスのエンドポイント バージョンより新しい                                          | リモート マシン上の wdEndpoint を互換性のあるバージョンに更新してください                                                                        |
| E\_ADMIN\_REQUIRED      | 0x8C114016 | 管理者特権が必要です。                 | エンドポイントが昇格された特権で実行されておらず、操作には管理者レベルのアクセス許可が必要                                            | エンドポイントを管理者として再実行してください                                                                                            |

## 解説

リモート デバイス上で同時に実行できるゲーム プロセスは 1 つだけです。ゲームが既に実行中の場合、この関数は自動的にそれを終了させて再度起動します。新しいゲームを起動する前に、[WdTerminateRemoteGame](/reference/remoting/functions/wdterminateremotegame) を使用して既存のゲームを終了することもできます。

[WdLaunchMode::Suspended](/reference/remoting/enums/wdlaunchmode) で起動した場合、ゲーム プロセスは中断状態で開始します。実行を再開するには [WdResumeRemoteGame](/reference/remoting/functions/wdresumeremotegame) を使用します。これは、ゲームが実行を開始する前にデバッガーをアタッチする場合に便利です。

## 例

### 例 1: リモート デバイス上でゲームを起動する

既定の設定 (即時実行、既定の共通ルート) を使用して、以前にコピーされたゲーム実行可能ファイルを起動します。

```cpp theme={null}
// LaunchGame.cpp
// Launches a game executable on a remote device.
// Build: Link against wdremoteapi.lib

#include <windows.h>
#include <stdio.h>
#include "WdRemoteIteration.h"

int main()
{
    // TODO: Replace with your remote device IP address or hostname
    const char* remoteDevice = "192.168.1.100";

    // TODO: Replace with the path to your game executable on the remote device.
    // Relative paths resolve against the default common root.
    const char* remotePath = "MyGame\\Binaries\\MyGame.exe";

    uint32_t processId = 0;
    uint32_t threadId  = 0;

    HRESULT hr = WdLaunchRemoteGame(
        remoteDevice,
        remotePath,
        nullptr,       // args — no command-line arguments
        nullptr,       // launchOptions — defaults to Immediate mode, default common root
        &processId,
        &threadId);

    if (SUCCEEDED(hr))
    {
        printf("Game launched — PID: %u, TID: %u\n", processId, threadId);
    }
    else
    {
        printf("Launch failed: HRESULT 0x%08X\n", hr);
    }

    return hr;
}
```

### 例 2: デバッグのために中断モードで起動する

実行が開始する前にデバッガーをアタッチできるように、ゲームを中断状態で起動します。デバッガーが接続された後、ユーザーが Enter キーを押してプロセスを再開します。

```cpp theme={null}
// LaunchSuspended.cpp
// Launches a game in suspended mode, waits for debugger attach, then resumes.
// Build: Link against wdremoteapi.lib

#include <windows.h>
#include <stdio.h>
#include "WdRemoteIteration.h"

int main()
{
    const char* remoteDevice = "192.168.1.100";
    const char* remotePath   = "MyGame\\Binaries\\MyGame.exe";

    WdLaunchOptions launchOptions = {};
    launchOptions.launchMode     = WdLaunchMode::Suspended;
    launchOptions.commonRootAlias = nullptr;  // Use default common root

    uint32_t processId = 0;
    uint32_t threadId  = 0;

    HRESULT hr = WdLaunchRemoteGame(
        remoteDevice,
        remotePath,
        "-debug -log",    // Command-line arguments passed to the executable
        &launchOptions,
        &processId,
        &threadId);

    if (FAILED(hr))
    {
        printf("Launch failed: HRESULT 0x%08X\n", hr);
        return hr;
    }

    printf("Game suspended — PID: %u\n", processId);
    printf("Attach your debugger to the remote process, then press Enter to resume...\n");
    getchar();

    hr = WdResumeRemoteGame(remoteDevice);
    if (SUCCEEDED(hr))
    {
        printf("Game resumed.\n");
    }
    else
    {
        printf("Resume failed: HRESULT 0x%08X\n", hr);
    }

    return hr;
}
```

### 例 3: コピーと起動のワークフロー

一般的なイテレーション サイクルを示します。ゲーム ファイルをリモート デバイスにコピーし、次に実行可能ファイルを起動します。これは、XBOX PC Remote Iteration API で最も一般的なエンドツーエンドのワークフローです。

```cpp theme={null}
// CopyAndLaunch.cpp
// Copies game files to a remote device, then launches the game.
// Build: Link against wdremoteapi.lib

#include <windows.h>
#include <stdio.h>
#include "WdRemoteIteration.h"

int main()
{
    // TODO: Replace these values with your own
    const char* remoteDevice   = "192.168.1.100";
    const char* localBuildPath = "C:\\builds\\MyGame";
    const char* gameFolderName = "MyGame";
    const char* gameExePath    = "MyGame\\Binaries\\MyGame.exe";

    // Step 1: Copy game files to the remote device
    printf("Copying files...\n");
    HRESULT hr = WdRemoteCopy(
        remoteDevice,
        localBuildPath,
        gameFolderName,
        nullptr, nullptr, nullptr, nullptr);

    if (FAILED(hr))
    {
        printf("Copy failed: HRESULT 0x%08X\n", hr);
        return hr;
    }

    // Step 2: Launch the game
    printf("Launching game...\n");
    hr = WdLaunchRemoteGame(
        remoteDevice,
        gameExePath,
        nullptr, nullptr, nullptr, nullptr);

    if (FAILED(hr))
    {
        printf("Launch failed: HRESULT 0x%08X\n", hr);
        return hr;
    }

    printf("Game files copied and launched successfully.\n");
    return 0;
}
```

## 要件

| 要件                   | 値                   |
| -------------------- | ------------------- |
| **ヘッダー**             | WdRemoteIteration.h |
| **ライブラリ**            | wdremoteapi.lib     |
| **サポートされている OS**     | Windows 11 以降       |
| **サポートされているアーキテクチャ** | x64、ARM64           |

## 関連項目

* [WdResumeRemoteGame](/reference/remoting/functions/wdresumeremotegame)
* [WdTerminateRemoteGame](/reference/remoting/functions/wdterminateremotegame)
* [WdLaunchOptions](/reference/remoting/structs/wdlaunchoptions)
* [WdLaunchMode](/reference/remoting/enums/wdlaunchmode)
* [XBOX PC Remote Iteration API エラー コード](/reference/remoting/error-codes)
* [XBOX PC Remote Iteration API](/reference/remoting/remoteiteration_members)


## Related topics

- [WdLaunchMode](/ja-jp/reference/remoting/enums/wdlaunchmode.md)
- [WdLaunchOptions](/ja-jp/reference/remoting/structs/wdlaunchoptions.md)
- [WdResumeRemoteGame](/ja-jp/reference/remoting/functions/wdresumeremotegame.md)
- [WdTerminateRemoteGame](/ja-jp/reference/remoting/functions/wdterminateremotegame.md)
- [WdRegisterRemoteXboxGame](/ja-jp/reference/remoting/functions/wdregisterremotexboxgame.md)
