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

# XPackageEstimateDownloadSize

> XPackageEstimateDownloadSize

# XPackageEstimateDownloadSize

計算符合指定安裝選取器之區塊的下載大小。

## 語法

```cpp theme={null}
HRESULT XPackageEstimateDownloadSize(  
         const char* packageIdentifier,  
         uint32_t selectorCount,  
         XPackageChunkSelector* selectors,  
         uint64_t* downloadSize,  
         bool* shouldPresentUserConfirmation  
)  
```

### 參數

*packageIdentifier*   \_In\_z\_\
類型：char\*

唯一識別磁碟上已安裝套件的字串。如需套件識別碼的詳細資訊，請參閱[管理可下載內容 (DLC) 及授權](/zh-TW/publishing/xstore-commerce/xstore-dlc)。

*selectorCount*   \_In\_\
類型：uint32\_t

*selectors* 參數中的選取器數目。

*selectors*   \_In\_reads\_(selectorCount)\
類型：[XPackageChunkSelector\*](/zh-TW/reference/system/xpackage/structs/xpackagechunkselector)

指定要操作之區塊的選取器陣列。

*downloadSize*   \_Out\_\
類型：uint64\_t\*

傳回時，包含指定安裝選取器的下載大小。

*shouldPresentUserConfirmation*   \_Out\_opt\_\
類型：bool\*

如果下載需要使用者確認，則傳回 true；否則傳回 false。

### 傳回值

類型：HRESULT

HRESULT 成功或錯誤碼。

## 備註

<Note>在時間敏感的執行緒上呼叫此函式並不安全。如需詳細資訊，請參閱[時間敏感的執行緒](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)。</Note>

如果有提供 *shouldPresentUserConfirmation* 參數，當估計的下載大小大到需要提示使用者接受下載大小時，此參數會設定為 true。

下列範例接受賽車遊戲的賽道名稱，如果賽道尚未安裝，則列印該賽道的下載大小：

```cpp theme={null}
HRESULT ListDownloadSize(char* trackName)
{
    XPackageChunkSelector selector;
    selector.type = XPackageChunkSelectorType::Tag;
    selector.tag = trackName;

    char id[XPACKAGE_IDENTIFIER_MAX_LENGTH];
    HRESULT hr = XPackageGetCurrentProcessPackageIdentifier(_countof(id), id);
    if (FAILED(hr)) return hr;

    XPackageChunkAvailability availability;
    hr = XPackageFindChunkAvailability(id, 1, &selector, &availability);
    if (FAILED(hr)) return hr;

    if (availability == XPackageChunkAvailability::Installable)
    {
        uint64_t downloadSize;
        hr = XPackageEstimateDownloadSize(id, 1, &selector, &downloadSize, nullptr);
        if (FAILED(hr)) return hr;

        printf("Download Size for track %s: %I64u\n", trackName, downloadSize);
    }

    return hr;
}
```

## 需求

**標頭：** XPackage.h

**程式庫：** xgameruntime.lib

**支援的平台：** Windows、XBOX One 系列主機與 XBOX Series 主機

## 概念文件

* [時間敏感的執行緒](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/overviews/threads/time-sensitive-threads)

## 另請參閱

[XPackage](/zh-TW/reference/system/xpackage/xpackage_members)\
[串流安裝與 Intelligent Delivery](/zh-TW/build/core-features/common/packaging/overviews/streaming_install-intelligent_delivery)


## Related topics

- [XPackageEstimateDownloadSize](/reference/system/xpackage/functions/xpackageestimatedownloadsize.md)
- [XPackageInstallChunksAsync](/reference/system/xpackage/functions/xpackageinstallchunksasync.md)
- [XPackageInstallChunks](/reference/system/xpackage/functions/xpackageinstallchunks.md)
