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

# PartyDevice::SetCustomContext

> 使用此设备对象配置可选的自定义指针大小上下文值。

使用此设备对象配置可选的自定义指针大小上下文值。

## Syntax

```cpp theme={null}
PartyError SetCustomContext(  
    void* customContext  
)  
```

### Parameters

**`customContext`**   void\*\
*optional*

要与设备对象一起存储的任意指针大小值。

### Return value

PartyError

如果配置自定义上下文成功，则返回 `c_partyErrorSuccess`；否则返回错误代码。可通过 [PartyManager::GetErrorMessage()](/services/playfab/multiplayer/networking/reference/classes/PartyManager/methods/partymanager_geterrormessage) 检索错误代码的可读形式。

## Remarks

自定义上下文通常用作"快捷方式"，可在无需映射查找的情况下简化对与设备关联的本地、标题特定内存的访问。可使用 [GetCustomContext()](/services/playfab/multiplayer/networking/reference/classes/PartyDevice/methods/partydevice_getcustomcontext) 方法检索该值。<br /><br /> 库将任何已配置的值视为不透明，且仅在本地设备上有效；它不会通过网络传输。

## Requirements

**Header:** Party.h

## See also

[PartyDevice](/services/playfab/multiplayer/networking/reference/classes/PartyDevice/partydevice)\
[PartyDevice::GetCustomContext](/services/playfab/multiplayer/networking/reference/classes/PartyDevice/methods/partydevice_getcustomcontext)


## Related topics

- [PartyDevice::GetCustomContext](/zh-CN/services/playfab/multiplayer/networking/reference/classes/PartyDevice/methods/partydevice_getcustomcontext.md)
- [PartyInvitation::SetCustomContext](/zh-CN/services/playfab/multiplayer/networking/reference/classes/PartyInvitation/methods/partyinvitation_setcustomcontext.md)
- [PartyNetwork::SetCustomContext](/zh-CN/services/playfab/multiplayer/networking/reference/classes/PartyNetwork/methods/partynetwork_setcustomcontext.md)
- [PartyEndpoint::SetCustomContext](/zh-CN/services/playfab/multiplayer/networking/reference/classes/PartyEndpoint/methods/partyendpoint_setcustomcontext.md)
- [PartyLocalUser::SetCustomContext](/zh-CN/services/playfab/multiplayer/networking/reference/classes/PartyLocalUser/methods/partylocaluser_setcustomcontext.md)
