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

# XStoreQueryGameLicenseAsync

> XStoreQueryGameLicenseAsync

# XStoreQueryGameLicenseAsync

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

## 構文

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

### パラメーター

*storeContextHandle*   \_In\_\
Type: XStoreContextHandle

[XStoreCreateContext](/reference/system/xstore/functions/xstorecreatecontext) から返される、ユーザーのストア コンテキスト ハンドル。

*async*   \_Inout\_\
Type: [XAsyncBlock\*](/reference/system/xasync/structs/xasyncblock)

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

### 戻り値

Type: HRESULT

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

## 解説

ライセンス情報とこの関数の実行結果を取得するには、この関数を呼び出した後に [XStoreQueryGameLicenseResult](/reference/system/xstore/functions/xstorequerygamelicenseresult) を呼び出します。[XStoreQueryGameLicenseResult](/reference/system/xstore/functions/xstorequerygamelicenseresult) は、**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 サポート](/build/core-features/common/packaging/packaging-mods)
* [ライセンス テストを有効にする](/publishing/xstore-commerce/xstore-licensing-setup)
* [GDK コマース システムの概要](/publishing/xstore-commerce/xstore-overview)
* [XStore の開発とテストを有効にする](/publishing/xstore-commerce/xstore-product-testing-setup)

## 関連項目

[XStore](/reference/system/xstore/xstore_members)\
[XStoreQueryGameLicenseResult](/reference/system/xstore/functions/xstorequerygamelicenseresult)\
[XStoreCreateContext](/reference/system/xstore/functions/xstorecreatecontext)


## Related topics

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