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

# XStoreQueryGameLicenseAsync

> XStoreQueryGameLicenseAsync

# XStoreQueryGameLicenseAsync

アプリの起動を許可するために取得されたライセンスに関する情報を取得します。

## 構文

```cpp theme={null}
HRESULT XStoreQueryGameLicenseAsync(  
         const XStoreContextHandle storeContextHandle,  
         XAsyncBlock* async  
)  
```

### パラメーター

*storeContextHandle*   \_In\_\
Type: XStoreContextHandle

[XStoreCreateContext](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorecreatecontext.md) から返される、ユーザーのストア コンテキスト ハンドル。

*async*   \_Inout\_\
Type: [XAsyncBlock\*](https://docs.xbox.com/ja-jp/reference/system/xasync/structs/xasyncblock.md)

実行中の非同期処理を定義する [XAsyncBlock](https://docs.xbox.com/ja-jp/reference/system/xasync/structs/xasyncblock.md)。[XAsyncBlock](https://docs.xbox.com/ja-jp/reference/system/xasync/structs/xasyncblock.md) は、呼び出しの状態のポーリングと呼び出し結果の取得に使用できます。詳細については、[XAsyncBlock](https://docs.xbox.com/ja-jp/reference/system/xasync/structs/xasyncblock.md) を参照してください。

### 戻り値

Type: HRESULT

HRESULT の成功またはエラー コード。

## 解説

ライセンス情報とこの関数の実行結果を取得するには、この関数を呼び出した後に [XStoreQueryGameLicenseResult](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorequerygamelicenseresult.md) を呼び出します。[XStoreQueryGameLicenseResult](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorequerygamelicenseresult.md) は、**XStoreQueryGameLicenseAsync** のコールバック関数内で呼び出す必要があります。次のコード スニペットは、ゲームの起動を許可するために取得されたライセンスのライセンス情報を取得する例を示しています。

```cpp theme={null}
void CALLBACK GameLicenseCallback(XAsyncBlock* asyncBlock)
{
    XStoreGameLicense result{};

    HRESULT hr = XStoreQueryGameLicenseResult(
        asyncBlock,
        &result);

    if (FAILED(hr))
    {
        printf("Failed retrieve the game license result: 0x%x\r\n", hr);
        return;
    }

    printf("expirationDate        : %d\r\n", result.expirationDate);
    printf("isActive              : %s\r\n", result.isActive ? "true" : "false");
    printf("isDiscLicense         : %s\r\n", result.isDiscLicense ? "true" : "false");
    printf("isTrial               : %s\r\n", result.isTrial ? "true" : "false");
    printf("isTrialOwnedByThisUser: %s\r\n", result.isTrialOwnedByThisUser ? "true" : "false");
    printf("skuStoreId            : %s\r\n", result.skuStoreId);
    printf("trialTimeRemaining    : %d\r\n", result.trialTimeRemainingInSeconds);
    printf("trialUniqueId         : %s\r\n", result.trialUniqueId);
}

void QueryGameLicense(XStoreContextHandle storeContextHandle, XTaskQueueHandle taskQueueHandle)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = taskQueueHandle;
    asyncBlock->callback = GameLicenseCallback;

    HRESULT hr = XStoreQueryGameLicenseAsync(
        storeContextHandle,
        asyncBlock.get());

    if (FAILED(hr))
    {
        printf("Failed to get the game license: 0x%x\r\n", hr);
        return;
    }
}
```

## 要件

**ヘッダー:** XStore.h (XGameRuntime.h に含まれる)

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

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

## 関連概念ドキュメント

* [PC GDK タイトルの Mod サポート](https://docs.xbox.com/ja-jp/build/core-features/common/packaging/packaging-mods.md)
* [ライセンス テストを有効にする](https://docs.xbox.com/ja-jp/publishing/xstore-commerce/xstore-licensing-setup.md)
* [GDK コマース システムの概要](https://docs.xbox.com/ja-jp/publishing/xstore-commerce/xstore-overview.md)
* [XStore の開発とテストを有効にする](https://docs.xbox.com/ja-jp/publishing/xstore-commerce/xstore-product-testing-setup.md)

## 関連項目

[XStore](https://docs.xbox.com/ja-jp/reference/system/xstore/xstore_members.md)\
[XStoreQueryGameLicenseResult](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorequerygamelicenseresult.md)\
[XStoreCreateContext](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorecreatecontext.md)


## Related topics

- [XStoreQueryGameLicenseResult](https://docs.xbox.com/ja-jp/reference/system/xstore/functions/xstorequerygamelicenseresult.md)
- [XStoreGameLicense](https://docs.xbox.com/ja-jp/reference/system/xstore/structs/xstoregamelicense.md)
- [ライセンス供与テストの有効化](https://docs.xbox.com/ja-jp/publishing/xstore-commerce/xstore-licensing-setup.md)
- [PC 上の XStore — DRM、ライセンス トークン、サンドボックス](https://docs.xbox.com/ja-jp/publishing/xstore-commerce/xstore-pc.md)
- [GDK コマース システムの概要](https://docs.xbox.com/ja-jp/publishing/xstore-commerce/xstore-overview.md)
