XStoreQueryProductForPackageAsync
检索指定包的应用商店产品信息。
语法
HRESULT XStoreQueryProductForPackageAsync(
const XStoreContextHandle storeContextHandle,
XStoreProductKind productKinds,
const char* packageIdentifier,
XAsyncBlock* async
)
参数
storeContextHandle _In_
类型:XStoreContextHandle
XStoreCreateContext 返回的用户的应用商店上下文句柄。
productKinds _In_
类型:XStoreProductKind
要查找的产品类型。
packageIdentifier _In_z_
类型:char*
唯一标识 Microsoft Store 包的字符串。 有关包标识符的详细信息,请参阅可下载内容 (DLC) 的管理和授权。
async _Inout_
类型:XAsyncBlock*
用于定义正在进行的异步工作的 XAsyncBlock。 XAsyncBlock 可用于轮询调用的状态和检索调用结果。 有关详细信息,请参阅 XAsyncBlock。
返回值
类型:HRESULT
HRESULT 成功或错误代码。
备注
要检索应用商店产品信息以及此函数的执行结果,请在调用此函数后调用 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);
return;
}
XTaskQueueHandle taskQueueHandle = reinterpret_cast<XTaskQueueHandle>(asyncBlock->context);
//Use result of query
}
void QueryProductForPackage(XStoreContextHandle storeContextHandle, XTaskQueueHandle taskQueueHandle, const char* packageIdentifier)
{
auto asyncBlock = std::make_unique<XAsyncBlock>();
ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
asyncBlock->queue = taskQueueHandle;
asyncBlock->context = 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;
}
// Wait a while for the callbacks to run
Sleep(5000);
}
要求
头文件:XStore.h(包含在 XGameRuntime.h 中)
库:xgameruntime.lib
支持平台:Windows、Xbox One 系列主机和 Xbox Series 主机
另请参阅
XStore
XStoreQueryProductForPackageResult
XStoreQueryAssociatedProductsAsync
XStoreQueryEntitledProductsAsync
XStoreQueryProductsAsync
XStoreQueryProductForCurrentGameAsync
XStoreQueryProductForPackageAsync