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

# XStoreRegisterPackageLicenseLost

> XStoreRegisterPackageLicenseLost

# XStoreRegisterPackageLicenseLost

為授權遺失事件註冊回呼。
使用此 API 來註冊透過 [XStoreAcquireLicenseForPackageAsync](https://docs.xbox.com/zh-TW/reference/system/xstore/functions/xstoreacquirelicenseforpackageasync.md) 和 [XStoreAcquireLicenseForDurablesAsync](https://docs.xbox.com/zh-TW/reference/system/xstore/functions/xstoreacquirelicensefordurablesasync.md) 取得的耐久性授權。

## 語法

```cpp theme={null}
HRESULT XStoreRegisterPackageLicenseLost(  
         XStoreLicenseHandle licenseHandle,  
         XTaskQueueHandle queue,  
         void* context,  
         XStorePackageLicenseLostCallback* callback,  
         XTaskQueueRegistrationToken* token  
)  
```

### 參數

*licenseHandle*   \_In\_\
類型：XStoreLicenseHandle

要為其註冊回呼的授權控制代碼。

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

用來處理非同步工作的非同步佇列。

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

要傳遞給回呼之由遊戲定義的內容。

*callback*   \_In\_\
類型：XStorePackageLicenseLostCallback\*

要註冊的回呼。

*token*   \_Out\_\
類型：[XTaskQueueRegistrationToken\*](https://docs.xbox.com/zh-TW/reference/system/xtaskqueue/structs/xtaskqueueregistrationtoken.md)

成功時，包含用來識別回呼的權杖。

### 傳回值

類型：HRESULT

HRESULT 成功或錯誤碼。

## 備註

此函式會註冊由 [XStorePackageLicenseLostCallback](https://docs.xbox.com/zh-TW/reference/system/xstore/functions/xstorepackagelicenselostcallback.md) 定義的回呼函式。
下一次發生耐久性授權遺失事件時，就會呼叫已註冊的回呼函式。
註冊期間不會呼叫回呼函式。
授權遺失事件通常發生在購買帳戶從裝置登出，且其先前共用的授權無法供目前使用者使用時。
為了避免記憶體流失，當您用完回呼函式時，必須呼叫 [XStoreUnregisterPackageLicenseLost](https://docs.xbox.com/zh-TW/reference/system/xstore/functions/xstoreunregisterpackagelicenselost.md)。

耐久性授權可能隨時因使用者變更、網路變更、並行檢查或裝置上的授權到期而遺失。
遊戲應該註冊授權遺失事件，並在回呼觸發時嘗試重新取得耐久性的授權。
授權遺失事件有助於偵測系統錯誤地將屬於另一個帳戶的快取授權傳回給目前玩家的情況。
在這種情況下，授權遺失事件會立即引發，而再次呼叫 XStoreAcquireLicense\* 時，就會提供全新的授權。

如需使用範例，請參閱 [XStoreAcquireLicenseForPackageAsync](https://docs.xbox.com/zh-TW/reference/system/xstore/functions/xstoreacquirelicenseforpackageasync.md)。

## 需求

**標頭：** XStore.h (包含在 XGameRuntime.h 中)

**程式庫：** xgameruntime.lib

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

## 概念文件

* [授與玩家附加元件內容的存取權](https://docs.xbox.com/zh-TW/publishing/xstore-commerce/xstore-granting-access.md)
* [啟用授權測試](https://docs.xbox.com/zh-TW/publishing/xstore-commerce/xstore-licensing-setup.md)

## 另請參閱

[XStore](https://docs.xbox.com/zh-TW/reference/system/xstore/xstore_members.md)\
[XStoreAcquireLicenseForPackageAsync](https://docs.xbox.com/zh-TW/reference/system/xstore/functions/xstoreacquirelicenseforpackageasync.md)\
[XStoreAcquireLicenseForPackageResult](https://docs.xbox.com/zh-TW/reference/system/xstore/functions/xstoreacquirelicenseforpackageresult.md)\
[XStoreIsLicenseValid](https://docs.xbox.com/zh-TW/reference/system/xstore/functions/xstoreislicensevalid.md)\
[XStoreCloseLicenseHandle](https://docs.xbox.com/zh-TW/reference/system/xstore/functions/xstorecloselicensehandle.md)\
[XStorePackageLicenseLostCallback](https://docs.xbox.com/zh-TW/reference/system/xstore/functions/xstorepackagelicenselostcallback.md)\
[XStoreUnregisterPackageLicenseLost](https://docs.xbox.com/zh-TW/reference/system/xstore/functions/xstoreunregisterpackagelicenselost.md)\
[授與玩家附加元件內容的存取權](https://docs.xbox.com/zh-TW/publishing/xstore-commerce/xstore-granting-access.md)


## Related topics

- [XStorePackageLicenseLostCallback](https://docs.xbox.com/zh-TW/reference/system/xstore/functions/xstorepackagelicenselostcallback.md)
- [XStoreUnregisterPackageLicenseLost](https://docs.xbox.com/zh-TW/reference/system/xstore/functions/xstoreunregisterpackagelicenselost.md)
- [XStoreAcquireLicenseForPackageResult](https://docs.xbox.com/zh-TW/reference/system/xstore/functions/xstoreacquirelicenseforpackageresult.md)
- [XStoreCloseLicenseHandle](https://docs.xbox.com/zh-TW/reference/system/xstore/functions/xstorecloselicensehandle.md)
- [XStoreIsLicenseValid](https://docs.xbox.com/zh-TW/reference/system/xstore/functions/xstoreislicensevalid.md)
