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

# XStoreRegisterGameLicenseChanged

> XStoreRegisterGameLicenseChanged

# XStoreRegisterGameLicenseChanged

为游戏许可证更改事件注册回调。
这仅适用于对正在运行的游戏许可证的更改，而不适用于任何耐用型 (DLC) 许可证。

## 语法

```cpp theme={null}
HRESULT XStoreRegisterGameLicenseChanged(  
         XStoreContextHandle storeContextHandle,  
         XTaskQueueHandle queue,  
         void* context,  
         XStoreGameLicenseChangedCallback* callback,  
         XTaskQueueRegistrationToken* token  
)  
```

### 参数

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

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

*queue*   \_In\_\
类型：XTaskQueueHandle

用于处理异步工作的异步队列。

*context*   \_In\_opt\_\
类型：void\*

要传递给回调的游戏定义上下文。

*callback*   \_In\_\
类型：XStoreGameLicenseChangedCallback\*

要注册的回调。

*token*   \_Out\_\
类型：[XTaskQueueRegistrationToken\*](/reference/system/xtaskqueue/structs/xtaskqueueregistrationtoken)

成功时，包含用于标识回调的令牌。

### 返回值

类型：HRESULT

HRESULT 成功或错误代码。

## 备注

此函数注册由 [XStoreGameLicenseChangedCallback](/reference/system/xstore/functions/xstoregamelicensechangedcallback) 定义的回调函数。
下一次发生游戏许可证更改事件时，将调用已注册的函数。
当此设备上发生与当前游戏相关的购买时，或者当游戏的许可证被刷新且游戏从试用许可证转为完整许可证时，会发生此事件。
注册操作本身不会调用已注册的函数。
为避免内存泄漏，当你使用完回调函数后，必须调用 [XStoreUnregisterGameLicenseChanged](/reference/system/xstore/functions/xstoreunregistergamelicensechanged)。

有关使用示例，请参阅 [XStoreCreateContext](/reference/system/xstore/functions/xstorecreatecontext)。

## 要求

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

**库：** xgameruntime.lib

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

## 概念文档

* [启用许可测试](/publishing/xstore-commerce/xstore-licensing-setup)

## 另请参阅

[XStore](/reference/system/xstore/xstore_members)\
[XStoreGameLicenseChangedCallback](/reference/system/xstore/functions/xstoregamelicensechangedcallback)\
[XStoreUnregisterGameLicenseChanged](/reference/system/xstore/functions/xstoreunregistergamelicensechanged)


## Related topics

- [XStoreUnregisterGameLicenseChanged](/zh-CN/reference/system/xstore/functions/xstoreunregistergamelicensechanged.md)
- [XStoreGameLicenseChangedCallback](/zh-CN/reference/system/xstore/functions/xstoregamelicensechangedcallback.md)
- [XStoreCreateContext](/zh-CN/reference/system/xstore/functions/xstorecreatecontext.md)
- [启用授权测试](/zh-CN/publishing/xstore-commerce/xstore-licensing-setup.md)
- [XTaskQueueRegistrationToken](/zh-CN/reference/system/xtaskqueue/structs/xtaskqueueregistrationtoken.md)
