> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XStoreAcquireLicenseForDurablesAsync

> XStoreAcquireLicenseForDurablesAsync

# XStoreAcquireLicenseForDurablesAsync

获取 DLC（带包的耐用型产品）、不带包的耐用型产品或耐用型加载项产品的许可证。

## 语法

```cpp theme={null}
HRESULT XStoreAcquireLicenseForDurablesAsync(
         const XStoreContextHandle storeContextHandle,
         const char* storeId,
         XAsyncBlock* async
)
```

### 参数

*storeContextHandle*   \_In\_\
类型：XStoreContextHandle

由 [XStoreCreateContext](https://docs.xbox.com/zh-CN/reference/system/xstore/functions/xstorecreatecontext.md) 返回的用户的商店上下文句柄。

*storeId*   \_In\_z\_\
类型：char\*

要获取许可证的耐用型产品的商店 ID。

*async*   \_Inout\_\
类型：XAsyncBlock\*

定义异步工作的 [XAsyncBlock](https://docs.xbox.com/zh-CN/reference/system/xasync/structs/xasyncblock.md)。
使用 [XAsyncBlock](https://docs.xbox.com/zh-CN/reference/system/xasync/structs/xasyncblock.md) 检查调用状态并获取调用结果。
有关详细信息，请参阅 [XAsyncBlock](https://docs.xbox.com/zh-CN/reference/system/xasync/structs/xasyncblock.md)。

### 返回值

类型：HRESULT

成功时返回 **S\_OK**，否则返回错误代码。

## 备注

此 API 尝试为请求的耐用型产品获取许可证。
如果是设备首次获取许可证，则会进行服务调用，因此需要联网连接。
后续对同一许可证的调用可能因缓存而更快，但许可证随时可能失效。
在主机上，脱机访问要求所属账户已启用"主 XBOX"，并且必须先在联机状态下获取一次许可证。
在 PC 上，脱机访问要求为拥有该许可证的账户设置"脱机权限"，并且必须先在联机状态下获取一次许可证。

可使用 [XStoreRegisterPackageLicenseLost](https://docs.xbox.com/zh-CN/reference/system/xstore/functions/xstoreregisterpackagelicenselost.md) 监视从此 API 获取的许可证是否丢失。

## 要求

**头文件：** XStore.h

**库：** xgameruntime.lib

**支持的平台**：Windows、XBOX One 系列主机和 XBOX Series 主机

## 概念文档

* [基本商店操作](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-basic-operations.md)
* [如何使用不带包的耐用型产品](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-dwob.md)
* [授予玩家访问加载项内容的权限](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-granting-access.md)
* [启用授权测试](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-licensing-setup.md)

## 另请参阅

[XStore](https://docs.xbox.com/zh-CN/reference/system/xstore/xstore_members.md)\
[XAsyncBlock](https://docs.xbox.com/zh-CN/reference/system/xasync/structs/xasyncblock.md)\
[XStoreAcquireLicenseForDurablesResult](https://docs.xbox.com/zh-CN/reference/system/xstore/functions/xstoreacquirelicensefordurablesresult.md)\
[如何使用不带包的耐用型产品](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-dwob.md)\
[授予玩家访问加载项内容的权限](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-granting-access.md)


## Related topics

- [XStoreAcquireLicenseForDurablesResult](https://docs.xbox.com/zh-CN/reference/system/xstore/functions/xstoreacquirelicensefordurablesresult.md)
- [XStoreAcquireLicenseForPackageAsync](https://docs.xbox.com/zh-CN/reference/system/xstore/functions/xstoreacquirelicenseforpackageasync.md)
- [XStoreRegisterPackageLicenseLost](https://docs.xbox.com/zh-CN/reference/system/xstore/functions/xstoreregisterpackagelicenselost.md)
- [启用授权测试](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-licensing-setup.md)
- [为玩家授予对附加内容的访问权限](https://docs.xbox.com/zh-CN/publishing/xstore-commerce/xstore-granting-access.md)
