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

# XStoreIsLicenseValid

> XStoreIsLicenseValid

# XStoreIsLicenseValid

检查指定的许可证是否有效。

## 语法

```cpp theme={null}
bool XStoreIsLicenseValid(  
         const XStoreLicenseHandle storeLicenseHandle  
)  
```

### 参数

*storeLicenseHandle*   \_In\_\
类型：XStoreLicenseHandle

许可证的句柄。

### 返回值

类型：bool

如果许可证有效，则返回 true；否则返回 false。

## 备注

此 API 可在时间敏感线程上安全调用。

有关用法示例，请参阅 [XStoreAcquireLicenseForPackageAsync](/reference/system/xstore/functions/xstoreacquirelicenseforpackageasync)。
使用 **XStoreIsLicenseValid** 可检查 [XStoreAcquireLicenseForPackageResult](/reference/system/xstore/functions/xstoreacquirelicenseforpackageresult) 或 [XStoreAcquireLicenseForDurablesResult](/reference/system/xstore/functions/xstoreacquirelicensefordurablesresult) 是否返回了有效的许可证。
如果许可证有效，则可以继续进行进一步的设置，例如注册基于许可证活动的回调函数。

<Note>此函数仅检查最初从 XStoreAcquireLicense\* API 获取时的静态许可证状态。
如果你已通过 [XStoreRegisterPackageLicenseLost](/reference/system/xstore/functions/xstoreregisterpackagelicenselost) 注册并且许可证变为无效，则应重新获取新的许可证以获得正确的状态，然后再次调用此 API。</Note>

## 要求

**头文件：** XStore.h（包含于 XGameRuntime.h 中）

**库：** xgameruntime.lib

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

## 概念文档

* [向玩家授予附加内容的访问权限](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-granting-access-to-content)

## 另请参阅

[XStore](/reference/system/xstore/xstore_members)\
[XStoreAcquireLicenseForPackageAsync](/reference/system/xstore/functions/xstoreacquirelicenseforpackageasync)\
[XStoreAcquireLicenseForPackageResult](/reference/system/xstore/functions/xstoreacquirelicenseforpackageresult)\
[XStoreIsLicenseValid](/reference/system/xstore/functions/xstoreislicensevalid)\
[XStoreCloseLicenseHandle](/reference/system/xstore/functions/xstorecloselicensehandle)\
[XStoreRegisterPackageLicenseLost](/reference/system/xstore/functions/xstoreregisterpackagelicenselost)\
[XStoreUnregisterPackageLicenseLost](/reference/system/xstore/functions/xstoreunregisterpackagelicenselost)\
[向玩家授予附加内容的访问权限](https://learn.microsoft.com/gaming/gdk/docs/store/commerce/fundamentals/xstore-granting-access-to-content)


## Related topics

- [XStoreCloseLicenseHandle](/zh-CN/reference/system/xstore/functions/xstorecloselicensehandle.md)
- [XStoreAcquireLicenseForPackageAsync](/zh-CN/reference/system/xstore/functions/xstoreacquirelicenseforpackageasync.md)
- [XStoreAcquireLicenseForPackageResult](/zh-CN/reference/system/xstore/functions/xstoreacquirelicenseforpackageresult.md)
- [XStoreRegisterPackageLicenseLost](/zh-CN/reference/system/xstore/functions/xstoreregisterpackagelicenselost.md)
- [XStoreUnregisterPackageLicenseLost](/zh-CN/reference/system/xstore/functions/xstoreunregisterpackagelicenselost.md)
