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

# XStoreCanAcquireLicenseForStoreIdAsync

> XStoreCanAcquireLicenseForStoreIdAsync

# XStoreCanAcquireLicenseForStoreIdAsync

パッケージの有無を問わず耐久型製品や、現在挿入されているディスク上のコンテンツなど、ライセンス付与可能なコンテンツのプレビュー ライセンスを取得します。
この API により、ゲームは実際にライセンスを取得することなく、その製品がライセンス付与可能かどうかを確認できます。

## Syntax

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

### Parameters

*storeContextHandle*   \_In\_\
型: XStoreContextHandle

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

*storeProductId*   \_In\_z\_\
型: char\*

確認する製品の StoreID。

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

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

### Return value

型: HRESULT

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

## Remarks

**XStoreCanAcquireLicenseForStoreIdAsync** は、ゲームが実際にライセンスを取得してそのユーザーの同時使用スロットを消費せずに、ユーザーが特定のコンテンツのライセンスを取得できるかどうかを判定する機能をゲームに提供します。
現在実行中のゲームは既にライセンスを持っているため、この関数を使用する必要はありませんが、ユーザーが同じ発行元の他のゲームやコンテンツを所有しているかどうかを判定できます。
たとえば、ゲームはこの API を使用して、ゲームの以前のバージョン (デジタルまたは挿入されたディスクから) を所有しているユーザーに報酬を提供するかどうか、またはユーザーに製品をアップセルするかどうかを判定できます。

プレビュー ライセンスとこの関数の実行結果を取得するには、この関数を呼び出した後に [XStoreCanAcquireLicenseForStoreIdResult](/reference/system/xstore/functions/xstorecanacquirelicenseforstoreidresult) を呼び出します。

このコード スニペットは、次の API の使用例を示しています。

* **XStoreCanAcquireLicenseForStoreIdAsync**
* [XStoreCanAcquireLicenseForStoreIdResult](/reference/system/xstore/functions/xstorecanacquirelicenseforstoreidresult)

```cpp theme={null}
void CALLBACK CanAcquireLicenseForStoreIdCallback(XAsyncBlock* asyncBlock)
{
    XStoreCanAcquireLicenseResult canAcquireLicenseResult{};

    HRESULT hr = XStoreCanAcquireLicenseForStoreIdResult(
        asyncBlock,
        &canAcquireLicenseResult);

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

    printf("status       : %d\r\n", canAcquireLicenseResult.status);
    printf("licensableSku: %s\r\n", canAcquireLicenseResult.licensableSku);
}

void CanAcquireLicenseForStoreId(XStoreContextHandle storeContextHandle, XTaskQueueHandle taskQueueHandle, const char* storeId)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = taskQueueHandle;
    asyncBlock->callback = CanAcquireLicenseForStoreIdCallback;

    HRESULT hr = XStoreCanAcquireLicenseForStoreIdAsync(
        storeContextHandle,
        storeId,
        asyncBlock.get());

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

## Requirements

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

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

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

## Conceptual documentation

* [プレイヤーへのアドオン コンテンツへのアクセス許可の付与](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-granting-access-to-content)
* [ダウンロード可能なコンテンツ (DLC) の管理およびライセンス](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-manage-and-license-optional-packages)
* [ライセンス テストの有効化](/publishing/xstore-commerce/xstore-licensing-setup)

## See also

[XStore](/reference/system/xstore/xstore_members)\
[XStoreCanAcquireLicenseForStoreIdResult](/reference/system/xstore/functions/xstorecanacquirelicenseforstoreidresult)\
[パッケージなしの耐久型を使用する方法](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-dwobs)\
[プレイヤーへのアドオン コンテンツへのアクセス許可の付与](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-granting-access-to-content)


## Related topics

- [XStoreCanAcquireLicenseForStoreIdResult](/ja-jp/reference/system/xstore/functions/xstorecanacquirelicenseforstoreidresult.md)
- [XStoreCanAcquireLicenseResult](/ja-jp/reference/system/xstore/structs/xstorecanacquirelicenseresult.md)
- [XStoreCanLicenseStatus](/ja-jp/reference/system/xstore/enums/xstorecanlicensestatus.md)
- [ライセンス供与テストの有効化](/ja-jp/publishing/xstore-commerce/xstore-licensing-setup.md)
- [プレイヤーにアドオン コンテンツへのアクセスを付与する](/ja-jp/publishing/xstore-commerce/xstore-granting-access.md)
