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

# WdSetDevice

> WdSetDevice

添加或更新已保存的设备记录。

**引入版本：** [RIT 0.0.14-preview](https://docs.xbox.com/zh-CN/reference/remoting/release-versions.md#release-versions)。

## 语法

```cpp theme={null}
HRESULT WD_REMOTE_ITERATION_CALL WdSetDevice(
    _In_z_ const char* remoteDevice,
    _In_opt_z_ const char* publicKeyHash
);
```

### 参数

`remoteDevice`\
类型：**const char\***

已保存设备的名称或 IP 地址，采用 UTF-8 编码。此操作作用于当前用户的本地目录。

`publicKeyHash`\
类型：**const char\***

最后观察到的配对设备 ID，或传递 `nullptr` 以将其清除。此值并非授权。

### 返回值

类型：**HRESULT**

成功时返回 `S_OK`；否则返回失败 HRESULT。目录操作还会返回[错误代码](https://docs.xbox.com/zh-CN/reference/remoting/error-codes.md)中所述的特定于目录的错误。

## 备注

保留由应用程序拥有的元数据。在空目录中记录的第一个设备会成为默认设备。`publicKeyHash` 是最后观察到的 40 个字符的十六进制配对设备 ID；传递 `nullptr` 可将其清除。哈希为空或格式不正确时返回 `E_INVALIDARG`。

保存记录不会配对设备、验证其当前身份或授予访问权限。

已保存设备 API 和配对 ID API 会更改不同的本地存储。它们不会取代远程 API 调用中显式的 `remoteDevice` 参数；需要默认选择的调用方必须自行解析默认设备。

## 要求

| 要求 | 值 |
| - | - |
| **头文件** | WdRemoteIteration.h |
| **库** | wdremoteapi.lib |
| **NuGet 包** | [Microsoft.GDK.RemoteIterationClientApi](https://aka.ms/GameDevRemoteAPI) |

## 另请参阅

* [XBOX PC 远程迭代 API](https://docs.xbox.com/zh-CN/reference/remoting/remoteiteration_members.md)


## Related topics

- [XBOX PC Remote Iteration API](https://docs.xbox.com/zh-CN/reference/remoting/remoteiteration_members.md)
- [WdSetDeviceProperty](https://docs.xbox.com/zh-CN/reference/remoting/functions/wdsetdeviceproperty.md)
- [WdSetDefaultDevice](https://docs.xbox.com/zh-CN/reference/remoting/functions/wdsetdefaultdevice.md)
- [WdEnumDevices](https://docs.xbox.com/zh-CN/reference/remoting/functions/wdenumdevices.md)
- [WdGetDevice](https://docs.xbox.com/zh-CN/reference/remoting/functions/wdgetdevice.md)
