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

# XStoreDownloadAndInstallPackagesAsync

> XStoreDownloadAndInstallPackagesAsync

# XStoreDownloadAndInstallPackagesAsync

지정된 스토어 패키지를 다운로드하고 설치합니다.

## 구문

```cpp theme={null}
HRESULT XStoreDownloadAndInstallPackagesAsync(  
         const XStoreContextHandle storeContextHandle,  
         const char** storeIds,  
         size_t storeIdsCount,  
         XAsyncBlock* async  
)  
```

### 매개 변수

*storeContextHandle*   \_In\_\
형식: XStoreContextHandle

[XStoreCreateContext](/reference/system/xstore/functions/xstorecreatecontext)가 반환한 사용자의 스토어 컨텍스트 핸들입니다.

*storeIds*   \_In\_z\_count\_(storeIdsCount)\
형식: char\*\*

패키지 식별자 문자열 목록입니다.
패키지 식별자는 Microsoft Store의 패키지를 고유하게 식별합니다. 패키지 식별자에 대한 자세한 내용은 [다운로드 가능한 콘텐츠(DLC) 관리 및 라이선스](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-manage-and-license-optional-packages)를 참조하세요.

*storeIdsCount*   \_In\_\
형식: size\_t

**storeIds**의 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)을 참조하세요.

### 반환 값

형식: [HRESULT](https://learn.microsoft.com/openspecs/windows_protocols/ms-erref/0642cb2f-2075-4469-918c-4441e69c548a)

HRESULT 성공 또는 오류 코드입니다.

## 설명

이 함수의 다운로드 및 설치 결과를 검색하려면 이 함수를 호출한 후 [XStoreDownloadAndInstallPackagesResult](/reference/system/xstore/functions/xstoredownloadandinstallpackagesresult)를 호출합니다. 다운로드 및 설치된 항목의 수를 검색하려면 이 함수를 호출한 후 [XStoreDownloadAndInstallPackagesResultCount](/reference/system/xstore/functions/xstoredownloadandinstallpackagesresultcount)를 호출합니다. 결과 카운트 함수는 결과 함수에 전달할 배열의 적절한 크기를 결정할 수 있게 해주므로 중요합니다.

이 API가 실행 중인 게임에서 호출되는 경우 다운로드는 높은 우선 순위로 간주되며 이 API의 storeIds 매개 변수에 지정된 순서대로 큐의 시작 부분으로 이동합니다.

다음 코드 조각은 스토어 패키지를 다운로드하고 설치하는 예를 보여 줍니다.

```cpp theme={null}
  
void CALLBACK DownloadAndInstallPackagesCallback(XAsyncBlock* asyncBlock)
{
    uint32_t count;

    HRESULT hr = XStoreDownloadAndInstallPackagesResultCount(
        asyncBlock,
        &count);

    if (FAILED(hr))
    {
        printf("Failed retrieve the installing packages count: 0x%x\r\n", hr);
        return;
    }

    printf("Number of updates: %d", count);

    auto packageIdentifiers = new char[count][XPACKAGE_IDENTIFIER_MAX_LENGTH];
    hr = XStoreDownloadAndInstallPackagesResult(
        asyncBlock,
        count,
        &packageIdentifiers[0]);

    if (FAILED(hr))
    {
        delete[] packageIdentifiers;
        printf("Failed retrieve the installing packages results: 0x%x\r\n", hr);
        return;
    }

    for (uint32_t index = 0; index < count; index++)
    {
        printf("packageIdentifier: %s\r\n", packageIdentifiers[index]);
    }

    delete[] packageIdentifiers;
}

void DownloadAndInstallPackages(XStoreContextHandle storeContextHandle, XTaskQueueHandle taskQueueHandle, const char** storeIds, size_t storeIdsCount)
{
    auto asyncBlock = std::make_unique<XAsyncBlock>();
    ZeroMemory(asyncBlock.get(), sizeof(*asyncBlock));
    asyncBlock->queue = taskQueueHandle;
    asyncBlock->callback = DownloadAndInstallPackagesCallback;

    HRESULT hr = XStoreDownloadAndInstallPackagesAsync(
        storeContextHandle,
        storeIds,
        storeIdsCount,
        asyncBlock.get());

    if (FAILED(hr))
    {
        printf("Failed to start download and install: 0x%x\r\n", hr);
        return;
    }
}
```

## 요구 사항

**헤더:** XStore.h(XGameRuntime.h에 포함됨)

**라이브러리:** xgameruntime.lib

**지원 플랫폼:** Windows, XBOX One 제품군 콘솔 및 XBOX Series 콘솔

## 개념 설명서

* [Manage and license downloadable content (DLC)](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-manage-and-license-optional-packages)

## 참고 항목

[XStore](/reference/system/xstore/xstore_members)\
[XStoreDownloadAndInstallPackagesResult](/reference/system/xstore/functions/xstoredownloadandinstallpackagesresult)\
[XStoreDownloadAndInstallPackagesResultCount](/reference/system/xstore/functions/xstoredownloadandinstallpackagesresultcount)


## Related topics

- [XStoreDownloadAndInstallPackagesResult](/ko/reference/system/xstore/functions/xstoredownloadandinstallpackagesresult.md)
- [XStoreDownloadAndInstallPackagesResultCount](/ko/reference/system/xstore/functions/xstoredownloadandinstallpackagesresultcount.md)
- [XStoreQueryPackageIdentifier](/ko/reference/system/xstore/functions/xstorequerypackageidentifier.md)
- [XStoreShowProductPageUIResult](/ko/reference/system/xstore/functions/xstoreshowproductpageuiresult.md)
- [다운로드 가능한 콘텐츠(DLC) 관리 및 라이선스](/ko/publishing/xstore-commerce/xstore-dlc.md)
