Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Retrieves a list of available updates for the packages specified in the argument. Use this list to download and install the updates.
Syntax
HRESULT XStoreQueryPackageUpdatesAsync (
const XStoreContextHandle storeContextHandle,
const char** packageIdentifiers,
size_t packageIdentifiersCount,
XAsyncBlock* async
)
Parameters
storeContextHandle _In_
Type: XStoreContextHandle
The store context handle for the user returned by XStoreCreateContext.
packageIdentifiers _In_z_count_(packageIdentifiersCount)
Type: char**
List of package identifier strings. A package identifier uniquely identifies a package from the Microsoft Store. For more information about package identifiers, see Manage and license downloadable content (DLC).
packageIdentifiersCount _In_
Type: size_t
The number of identifiers in packageIdentifiers.
async _Inout_
Type: XAsyncBlock*
An XAsyncBlock that defines the asynchronous work. Use the XAsyncBlock to poll for the call's status and retrieve call results. For more information, see XAsyncBlock.
Return value
Type: HRESULT
HRESULT success or error code.
Remarks
To get the package identifier of the currently running game, use XPackageGetCurrentProcessPackageIdentifier or use XPackageEnumeratePackages to get the package identifiers of DLC and related games.
To retrieve the list of available updates and the execution result of this function, call XStoreQueryPackageUpdatesResult after calling this function. To get the number of updates to retrieve, call XStoreQueryPackageUpdatesResultCount after calling this function. The result count function is important as it allows you to determine the appropriate size of array to pass to the result function.
The following code snippet shows an example of retrieving game and optional updates for the packages specified.
void CALLBACK QueryPackageUpdatesCallback(XAsyncBlock* asyncBlock)
{
uint32_t count;
HRESULT hr = XStoreQueryPackageUpdatesResultCount(
asyncBlock,
&count);
if (FAILED(hr))
{
printf("XStoreQueryPackageUpdatesResultCount failed : 0x%x\n", hr);
return;
}
printf("Number of updates: %d", count);
if (count > 0)
{
XStorePackageUpdate* updates = new XStorePackageUpdate[count];
hr = XStoreQueryPackageUpdatesResult(
asyncBlock,
count,
updates);
if (FAILED(hr))
{
delete[] updates;
printf("XStoreQueryPackageUpdatesResult failed: 0x%x\n", hr);
return;
}
for (uint32_t index = 0; index < count; index++)
{
printf("Update found for packageIdentifier: %s\n", updates[index].packageIdentifier);
// Proceed to XStoreDownloadAndInstallPackageUpdates flow
}
delete[] updates;
}
}
void QueryPackageUpdates(XStoreContextHandle storeContextHandle, XTaskQueueHandle taskQueueHandle)
{
std::vector<std::string> packageIds;
HRESULT hr = XPackageEnumeratePackages(
XPackageKind::Game,
XPackageEnumerationScope::ThisAndRelated,
&packageIds, [](void* context, const XPackageDetails* details) -> bool
{
auto packageIds = reinterpret_cast<std::vector<std::string>*>(context);
printf("Identifier: %s name: %s\n", details->packageIdentifier, details->displayName);
packageIds->push_back(details->packageIdentifier);
});
// packageIds now populated with ids for all installed packages
auto asyncBlock = new XAsyncBlock();
asyncBlock->queue = m_asyncQueue;
asyncBlock->callback = QueryPackageUpdatesCallback;
hr = XStoreQueryPackageUpdatesAsync(
m_storeContext,
packageIds.data(),
packageIds.size(),
asyncBlock);
if (FAILED(hr))
{
printf("XStoreQueryPackageUpdatesAsync failed: 0x%x\n", hr);
return;
}
}
Requirements
Header: XStore.h (included in XGameRuntime.h)
Library: xgameruntime.lib
Supported platforms: Windows, Xbox One family consoles, and Xbox Series consoles
See also
XStore
XStoreQueryPackageUpdatesResult
XStoreQueryPackageUpdatesResultCount