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

# XStoreQueryPackageUpdatesAsync

> XStoreQueryPackageUpdatesAsync

# XStoreQueryPackageUpdatesAsync

Retrieves a list of available updates for the packages specified in the argument. Use this list to download and install the updates.

## Syntax

```cpp theme={null}
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](/reference/system/xstore/functions/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)](/publishing/xstore-commerce/xstore-dlc).

*packageIdentifiersCount*   \_In\_\
Type: size\_t

The number of identifiers in `packageIdentifiers`.

*async*   \_Inout\_\
Type: [XAsyncBlock\*](/reference/system/xasync/structs/xasyncblock)

An [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) that defines the asynchronous work. Use the [XAsyncBlock](/reference/system/xasync/structs/xasyncblock) to poll for the call's status and retrieve call results. For more information, see [XAsyncBlock](/reference/system/xasync/structs/xasyncblock).

### Return value

Type: HRESULT

HRESULT success or error code.

## Remarks

To get the package identifier of the currently running game, use [XPackageGetCurrentProcessPackageIdentifier](/reference/system/xpackage/functions/xpackagegetcurrentprocesspackageidentifier) or use [XPackageEnumeratePackages](/reference/system/xpackage/functions/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](/reference/system/xstore/functions/xstorequerypackageupdatesresult) after calling this function. To get the number of updates to retrieve, call [XStoreQueryPackageUpdatesResultCount](/reference/system/xstore/functions/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.

```cpp theme={null}
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

## Conceptual documentation

* [Checking for updates](/publishing/xstore-commerce/xstore-checking-updates)

## See also

[XStore](/reference/system/xstore/xstore_members)\
[XStoreQueryPackageUpdatesResult](/reference/system/xstore/functions/xstorequerypackageupdatesresult)\
[XStoreQueryPackageUpdatesResultCount](/reference/system/xstore/functions/xstorequerygameanddlcpackageupdatesresultcount)


## Related topics

- [XStoreQueryPackageUpdatesResult](/reference/system/xstore/functions/xstorequerypackageupdatesresult.md)
- [XStoreQueryPackageUpdatesResultCount](/reference/system/xstore/functions/xstorequerypackageupdatesresultcount.md)
- [Checking for updates](/publishing/xstore-commerce/xstore-checking-updates.md)
- [XStore](/reference/system/xstore/xstore_members.md)
- [XStoreQueryGameAndDlcPackageUpdatesAsync](/reference/system/xstore/functions/xstorequerygameanddlcpackageupdatesasync.md)
