次の方法で共有


XStoreQueryProductForPackageAsync

指定されたパッケージに関する Microsoft Store の製品情報を取得します。

構文

HRESULT XStoreQueryProductForPackageAsync(  
         const XStoreContextHandle storeContextHandle,  
         XStoreProductKind productKinds,  
         const char* packageIdentifier,  
         XAsyncBlock* async  
)  

パラメーター

storeContextHandle _In_
型: XStoreContextHandle

XStoreCreateContext によって返されるユーザーの Microsoft Store コンテキスト ハンドル。

productKinds _In_
型: XStoreProductKind

検索する製品の種類。

packageIdentifier _In_z_
型: char*

Microsoft Store パッケージを一意に識別する文字列。 パッケージ識別子の詳細については、「ダウンロード可能なコンテンツ (DLC) の管理とライセンス」を参照してください。

async _Inout_
型: XAsyncBlock*

行われている非同期処理が定義されている XAsyncBlockXAsyncBlock を使用して、呼び出しのステータスをポーリングし、呼び出しの結果を取得できます。 詳細については、「XAsyncBlock」を参照してください。

戻り値

型: HRESULT

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

解説

この関数の実行結果と Microsoft Store 製品情報を取得するには、この関数を呼び出した後で、XStoreQueryProductForPackageResult を呼び出します。

次のコード スニペットでは、パッケージの製品情報を取得する例を示します。

void CALLBACK QueryProductForPackageCallback(XAsyncBlock* asyncBlock)
{
    XStoreProductQueryHandle queryHandle = nullptr;

    HRESULT hr = XStoreQueryProductForPackageResult(
        asyncBlock,
        &queryHandle);

    if (FAILED(hr))
    {
        printf("Failed retrieve the product query handle: 0x%x\r\n", hr);
        XStoreCloseProductsQueryHandle(queryHandle);
        return;
    }

    // Use result of query

     XStoreCloseProductsQueryHandle(queryHandle);
}

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

    XStoreProductKind allProductKinds =
        XStoreProductKind::Consumable |
        XStoreProductKind::Durable |
        XStoreProductKind::Game |
        XStoreProductKind::Pass |
        XStoreProductKind::UnmanagedConsumable;

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

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


要件

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

ライブラリ: xgameruntime.lib

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

関連項目

XStore
XStoreQueryProductForPackageResult
XStoreQueryAssociatedProductsAsync
XStoreQueryEntitledProductsAsync
XStoreQueryProductsAsync
XStoreQueryProductForCurrentGameAsync
XStoreQueryProductForPackageAsync