Play Games PC SDK を使用すると、Google Play サービスにアクセスして、PC でゲームを構築し、収益化できます。Play 請求サービスを使用してデジタル コンテンツを販売し、Play Games を使用してシームレスにログインし、Play Integrity を使用してユーザーがアプリの有効な利用資格を持っていることを確認できます。
準備ができたら
前提条件
Google Play Console 内でアプリ エントリを作成し、Google Play パッケージ名を請求します。
GooglePlayInitialize を呼び出して API を初期化し、SDK の使用を開始します。これにより、グローバル状態が設定され、SDK ランタイムに接続され、アプリケーションが正しく起動されたことが確認されます。他の API を使用する前に、このメソッドを呼び出し、継続コールバックを InitializeResult::ok() が true に等しい状態で完了させる必要があります。
// Initialize the SDK as part of the startup sequence of your application.autopromise=std::make_shared<std::promise<InitializeResult>>();GooglePlayInitialize([promise](InitializeResultresult){promise->set_value(std::move(result));});autoinitialize_result=promise->get_future().get();if(initialize_result.ok()){// The SDK succeeded with initialization. Continue with the startup sequence// of the game.// ...}elseif(initialize_result.code()==InitializationError::kActionRequiredShutdownClientProcess){// The SDK failed to initialize and has requested that your game process exit// as soon as possible.exit(1);}else{// The SDK failed to initialize for an alternative reason. It is still// generally recommended that you exit the game process as soon as possible,// because it won't be possible to access any APIs in the SDK. Critical// operations such as verifying the user owns a valid license to your game// won't be possible.// ...}
初期化がコード kActionRequiredShutdownClientProcess で失敗した場合は、できるだけ早くゲームプロセスを終了します。SDK のランタイムは、ゲームで追加の操作を行うことなく、ユーザーをサポートしようとします。たとえば、ユーザーがゲームの有効なライセンスを所有していない場合、Google Play Games はユーザーにコピーの購入を促します。その他のエラーについては、SDK を使用して、ユーザーがゲームの有効なライセンスを所有していることを確認するなどの重要なオペレーションを実行できないため、できるだけ早くゲーム プロセスを終了することをおすすめします。
この例では、PC 版 Google Play Games(GooglePlayGames.exe)がいくつかのパラメータ(--foo=abc --bar=123)を使用してゲーム(YourGameLauncher.exe)を起動するプロセス階層を示しています。ゲームは、Play Games PC SDK を使用する子プロセス(YourGame.exe)を生成します。これを可能にするため、PC 版 Google Play Games によって起動されたゲームプロセスは、与えられたコマンドライン パラメータを子プロセスに転送します。
ゲームの実行が停止したら、すべてのプロセスを終了します。
ユーザーがゲームを終了した場合や、SDK の初期化の失敗(kActionRequiredShutdownClientProcess など)によりゲームが終了した場合は、ゲームが生成したすべてのプロセスを終了します。これにより、次回 PC 版 Google Play Games クライアントでゲームが起動されたときに、アクティブなアカウントの切り替えなどの新しい変更が有効になります。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-29 UTC。"],[],[],null,["# Power your game using the Play Games PC SDK\n\nWith the Play Games PC SDK you can access Google Play services to build and\nmonetize your game on PCs. Sell digital content using Play Billing, seamlessly\nsign-in using Play Games, and ensure your users have a valid entitlement to your\napplication with Play Integrity.\n\nReady to get started?\n\nPrerequisites\n-------------\n\n- Create an app entry inside of the Play Console and claim a Play package name.\n\n- Download and install\n [Google Play Games for PC](https://play.google.com/googleplaygames) and sign in with\n your Google Account.\n\n**Step 1**: Add the SDK to your project\n---------------------------------------\n\n| **Note:** The SDK officially supports C++. If you are using a programming language other than C++ please reach out to your Google Partner letting them know what game engine \\& programing language your application uses to see if we can better support you.\n\n- Download the [Play Games PC C++ SDK](/games/playgames/native-pc/downloads/cpp).\n\n- Copy the API headers folder `includes/` into your application's codebase.\n\n- Copy the redistributable files from `imports/` into your application's\n project.\n\n - Link your project against `play_pc_sdk.lib` allowing access to the contents of the `play_pc_sdk.dll`.\n\n**Step 2**: Add a manifest file\n-------------------------------\n\nBefore you can use the SDK from within your game you will need to\nassociate your game executable with the Play package name that you claimed\ninside of the Play Console. This done by adding a `manifest.xml` file in the\nsame directory as your game's executable.\n\nExample `manifest.xml` contents: \n\n \u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n \u003cManifest version=\"1\"\u003e\n \u003cApplication\u003e\n \u003cPackageName\u003e\u003cvar translate=\"no\"\u003ecom.example.package\u003c/var\u003e\u003c/PackageName\u003e\n \u003c/Application\u003e\n \u003c/Manifest\u003e\n\nExample `manifest.xml` placement: \n\n C:\\Program Files\n └───Example Game\n ├───Game.exe\n └───manifest.xml\n\n**Step 3**: Digitally sign your game\n------------------------------------\n\n| **Tip:** Developers can skip this step during local development by enabling [developer mode](/games/playgames/native-pc/setup/developer_mode).\n\nBefore your game can use the SDK, the game's executable must be digitally signed\nusing an\n[Authenticode Digital Signature](https://learn.microsoft.com/en-us/windows-hardware/drivers/install/authenticode).\nFor instructions on how to sign an executable see the\n[documentation on the SignTool](https://learn.microsoft.com/en-us/windows/win32/seccrypto/signtool) .\n\n**Step 4**: Initialize the SDK\n------------------------------\n\nInitialize the SDK during the startup sequence of your game. This should be done\nautomatically without requiring any user interaction and it is recommended to\nverify a successful initialization before rendering your game window.\nThis provides the best user experience by surfacing and resolving errors as soon\nas possible and avoids your game window briefly appearing in cases where your\ngame process needs to exit.\n\nStart using the SDK by calling\n[`GooglePlayInitialize`](/games/playgames/native-pc/reference/namespace/google/play/initialization) to initialize the API. This\nwill setup global state, connect with the SDK runtime, and verify the\napplication was started correctly. This **MUST** be called and have the\ncontinuation callback complete with `InitializeResult::ok()` equal to `true`\nbefore any other API may be used. \n\n // Initialize the SDK as part of the startup sequence of your application.\n auto promise = std::make_shared\u003cstd::promise\u003cInitializeResult\u003e\u003e();\n GooglePlayInitialize(\n [promise](InitializeResult result) {\n promise-\u003eset_value(std::move(result));\n });\n\n auto initialize_result = promise-\u003eget_future().get();\n if (initialize_result.ok()) {\n // The SDK succeeded with initialization. Continue with the startup sequence\n // of the game.\n // ...\n } else if (initialize_result.code() == InitializationError::kActionRequiredShutdownClientProcess) {\n // The SDK failed to initialize and has requested that your game process exit\n // as soon as possible.\n exit(1);\n } else {\n // The SDK failed to initialize for an alternative reason. It is still\n // generally recommended that you exit the game process as soon as possible,\n // because it won't be possible to access any APIs in the SDK. Critical\n // operations such as verifying the user owns a valid license to your game\n // won't be possible.\n // ...\n }\n\nIf the initialization fails with the code `kActionRequiredShutdownClientProcess`\n**exit the game process as soon possible**. The SDK's runtime will attempt\nto assist the user with no additional action required by your game. For example\nif the user does not own a valid license to the game, Google Play Games will\nprompt the user to purchase a copy. For other errors it is still recommended to\nexit the game process as soon as possible as it won't to use the SDK to\nperform critical operations such as verifying the user owns a valid license\nto your game.\n\nA non-successful response may indicate one of the following conditions:\n\n- The SDK runtime is not installed, is not running on the device or is\n an older version not compatible with the SDK integrated into your game.\n\n- The SDK runtime was unable to verify the application identity of the\n game. This could be due to an invalid `manifest.xml` or using the SDK\n without enabling [developer mode](/games/playgames/native-pc/setup/developer_mode)\n when developing. Without this your game's executable is required to be\n digitally signed with the digital certificate registered to your Play package\n name.\n\n- The game executable was not launched through the Google Play games client.\n\n- The active user in Google Play Games does not own a license for the\n application.\n\n**Step 5**: (Optional) Supporting multiple game-processes\n---------------------------------------------------------\n\nIf your game uses multiple processes and plans to use the Play Games PC SDK from\na process that is not directly launched by Google Play Games for PC additional\nintegration steps are required:\n\n1. The process directly launched by Google Play Games for PC must\n verify a successful [initialization of the Play Games PC SDK](#step-4).\n\n This provides the best user experience by surfacing errors as soon as\n possible. Note that child-process using the SDK must also perform\n initialization in addition to the directly launched process.\n2. To use the Play Games PC SDK in a child-process forward the command line\n parameters to the spawned child-process.\n\n Example command line parameter forwarding: \n\n Processes hierarchy tree:\n\n GooglePlayGames.exe\n └───YourGameLauncher.exe --foo=abc --bar=123\n └───YourGame.exe --foo=abc --bar=123\n\n In this example we see a process hierarchy where Google Play Games for PC\n (`GooglePlayGames.exe`) launches the game (`YourGameLauncher.exe`) with some\n example parameters (`--foo=abc --bar=123`). The game then spawns a\n child-process (`YourGame.exe`) which uses the Play Games PC SDK. To allow this\n the game process launched by Google Play Games for PC forwards the command\n line parameters it was given to the child-process.\n3. Exit all processes when the game stops running.\n\n When a user closes your game or the game exits due to a SDK initialization\n failure, such as `kActionRequiredShutdownClientProcess`, close all processes\n your game has spawned. This makes certain that the next time your game is\n launched by the Google Play Games for PC client, new changes such as switching\n to a different active account will take effect.\n\nNext steps\n----------\n\nUse the SDK while developing in your IDE:\n\n- Enable [developer mode](/games/playgames/native-pc/setup/developer_mode)\n\nAdd Google Play PC features to your app:\n\n- Sell digital goods with [Play Billing](/games/playgames/native-pc/billing)\n- Measure your marketing with [Play Install Referrer](/games/playgames/native-pc/install_referrer)"]]