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

# XStoreAcquireLicenseForDurablesAsync

> XStoreAcquireLicenseForDurablesAsync

# XStoreAcquireLicenseForDurablesAsync

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

<a id="syntaxSection" />

## 语法

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

<a id="parametersSection" />

### 参数

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

由 [XStoreCreateContext](/reference/system/xstore/functions/xstorecreatecontext) 返回的用户的商店上下文句柄。

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

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

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

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

<a id="retvalSection" />

### 返回值

类型：HRESULT

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

<a id="remarksSection" />

## 备注

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

可使用 [XStoreRegisterPackageLicenseLost](/reference/system/xstore/functions/xstoreregisterpackagelicenselost) 监视从此 API 获取的许可证是否丢失。

<a id="requirementsSection" />

## 要求

**头文件：** XStore.h

**库：** xgameruntime.lib

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

<a id="seealsoSection" />

## 概念文档

* [基本商店操作](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-basic-store-operations)
* [如何使用不带包的耐用型产品](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-dwobs)
* [授予玩家访问加载项内容的权限](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-granting-access-to-content)
* [启用授权测试](/publishing/xstore-commerce/xstore-licensing-setup)

## 另请参阅

[XStore](/reference/system/xstore/xstore_members)\
[XAsyncBlock](/reference/system/xasync/structs/xasyncblock)\
[XStoreAcquireLicenseForDurablesResult](/reference/system/xstore/functions/xstoreacquirelicensefordurablesresult)\
[如何使用不带包的耐用型产品](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-dwobs)\
[授予玩家访问加载项内容的权限](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-granting-access-to-content)


## Related topics

- [XStoreAcquireLicenseForDurablesResult](/zh-CN/reference/system/xstore/functions/xstoreacquirelicensefordurablesresult.md)
- [XStoreAcquireLicenseForPackageAsync](/zh-CN/reference/system/xstore/functions/xstoreacquirelicenseforpackageasync.md)
- [XStoreRegisterPackageLicenseLost](/zh-CN/reference/system/xstore/functions/xstoreregisterpackagelicenselost.md)
- [启用授权测试](/zh-CN/publishing/xstore-commerce/xstore-licensing-setup.md)
- [XStoreQueryAddOnLicensesAsync](/zh-CN/reference/system/xstore/functions/xstorequeryaddonlicensesasync.md)
