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

# XStoreShowGiftingUIAsync

> XStoreShowGiftingUIAsync

# XStoreShowGiftingUIAsync

指定した製品を別のユーザーへのギフトとして購入するための UI オーバーレイを開始します。現在のユーザーは、ギフトの受取人に関する情報の入力を求められ、購入フローを案内されます。

## Syntax

```cpp theme={null}
HRESULT XStoreShowGiftingUIAsync(  
         const XStoreContextHandle storeContextHandle,  
         const char* storeId,  
         const char* name,  
         const char* extendedJsonData,  
         XAsyncBlock* async  
)  
```

### Parameters

*storeContextHandle*   \_In\_\
型: XStoreContextHandle

[XStoreCreateContext](/reference/system/xstore/functions/xstorecreatecontext) によって返されたユーザーのストア コンテキスト ハンドル。

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

ギフトとして購入する製品の ID。**注**: この製品はギフト購入をサポートするように構成されている必要があります。

*name*   \_In\_opt\_z\_\
型: char\*

ギフトとして購入する製品の名前。

*extendedJsonData*   \_In\_opt\_z\_\
型: char\*

ギフト購入フローに渡される JSON ブロブ。カスタム キャンペーン ID を挿入できるため、購入の開始経路を追跡できます。

*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

ギフトとして購入する製品は、ギフト購入をサポートするように構成されている必要があります。ギフトをサポートする製品のリストを取得するには、`actionFilters` パラメーターを `"Gift"` に設定して [XStoreQueryProductsAsync](/reference/system/xstore/functions/xstorequeryproductsasync) を呼び出します。

この関数の結果を取得するには、この関数を呼び出した後に [XStoreShowGiftingUIResult](/reference/system/xstore/functions/xstoreshowgiftinguiresult) を呼び出します。この関数は、ユーザーがギフトとして何かを購入することを選択したときにのみ呼び出す必要があり、支払い情報の入力とユーザー確認をプロセス外で処理するモーダル購入ダイアログをシステムに表示させます。

次のコード スニペットは、特定のストア製品のギフト購入を要求する例を示しています。

```cpp theme={null}
void CALLBACK ShowGiftingUICallback(XAsyncBlock* asyncBlock)
{
    HRESULT hr = XStoreShowGiftingUIResult(asyncBlock);

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

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

    HRESULT hr = XStoreShowGiftingUIAsync(
        storeContextHandle,
        storeId,
        nullptr,    // Can be used to override the title bar text
        nullptr,    // Can be used to provide extra details to purchase
        asyncBlock.get());

    if (FAILED(hr))
    {
        printf("Failed to purchase: 0x%x\r\n", hr);
        return;
    }
}


```

## Requirements

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

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

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

## See also

[XStore](/reference/system/xstore/xstore_members)\
[XStoreShowGiftingUIResult](/reference/system/xstore/functions/xstoreshowgiftinguiresult)


## Related topics

- [XStoreShowGiftingUIResult](/ja-jp/reference/system/xstore/functions/xstoreshowgiftinguiresult.md)
- [XStore](/ja-jp/reference/system/xstore/xstore_members.md)
- [XStoreShowPurchaseUIAsync](/ja-jp/reference/system/xstore/functions/xstoreshowpurchaseuiasync.md)
- [XStoreShowAssociatedProductsUIAsync](/ja-jp/reference/system/xstore/functions/xstoreshowassociatedproductsuiasync.md)
- [XStoreShowProductPageUIAsync](/ja-jp/reference/system/xstore/functions/xstoreshowproductpageuiasync.md)
