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

# XStoreCanAcquireLicenseForPackageAsync

> XStoreCanAcquireLicenseForPackageAsync

# XStoreCanAcquireLicenseForPackageAsync

DLC (パッケージ付きの耐久型) のプレビュー ライセンスを取得します。
この API により、ゲームは実際にライセンスを取得せずに、耐久型のパッケージがライセンス付与可能かどうかを確認できます。

## Syntax

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

### Parameters

*storeContextHandle*   \_In\_\
型: XStoreContextHandle

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

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

ストア パッケージを一意に識別する文字列。パッケージ識別子の詳細については、[ダウンロード可能なコンテンツ (DLC) の管理およびライセンス](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-manage-and-license-optional-packages) を参照してください。

*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

プレビュー ライセンスとこの関数の実行結果を取得するには、この関数を呼び出した後に [XStoreCanAcquireLicenseForPackageResult](/reference/system/xstore/functions/xstorecanacquirelicenseforpackageresult) を呼び出します。
この関数はオンライン接続を必要とし、パッケージのライセンスを取得できるかどうかを確認するだけです。
パッケージのライセンスを取得するには、[XStoreAcquireLicenseForPackageAsync](/reference/system/xstore/functions/xstoreacquirelicenseforpackageasync) を呼び出します。

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

* [XStoreCanAcquireLicenseForPackageAsync](/reference/system/xstore/functions/xstorecanacquirelicenseforpackageasync)
* [XStoreCanAcquireLicenseForPackageResult](/reference/system/xstore/functions/xstorecanacquirelicenseforpackageresult)

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

    HRESULT hr = XStoreCanAcquireLicenseForPackageResult(
        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 CanAcquireLicenseForPackage(XStoreContextHandle storeContextHandle, XTaskQueueHandle taskQueueHandle, const char* packageIdentifier)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = taskQueueHandle;
    asyncBlock->callback = CanAcquireLicenseForPackageCallback;

    HRESULT hr = XStoreCanAcquireLicenseForPackageAsync(
        storeContextHandle,
        packageIdentifier,
        asyncBlock.get());

    if (FAILED(hr))
    {
        printf("Failed to get preview license for package: 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)\
[XStoreCanAcquireLicenseForPackageResult](/reference/system/xstore/functions/xstorecanacquirelicenseforpackageresult)\
[XStoreAcquireLicenseForPackageAsync](/reference/system/xstore/functions/xstoreacquirelicenseforpackageasync)\
[ダウンロード可能なコンテンツ (DLC) の管理およびライセンス](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-manage-and-license-optional-packages)


## Related topics

- [XStoreCanAcquireLicenseForPackageResult](/ja-jp/reference/system/xstore/functions/xstorecanacquirelicenseforpackageresult.md)
- [XStoreCanAcquireLicenseResult](/ja-jp/reference/system/xstore/structs/xstorecanacquirelicenseresult.md)
- [XStoreAcquireLicenseForPackageAsync](/ja-jp/reference/system/xstore/functions/xstoreacquirelicenseforpackageasync.md)
- [XStoreCanLicenseStatus](/ja-jp/reference/system/xstore/enums/xstorecanlicensestatus.md)
- [ライセンス供与テストの有効化](/ja-jp/publishing/xstore-commerce/xstore-licensing-setup.md)
