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

# WdSetDefaultDevice

> WdSetDefaultDevice

设置或清除已保存的默认设备。

**引入版本：** [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 WdSetDefaultDevice(
    _In_opt_z_ const char* remoteDevice,
    _In_ bool createIfMissing
);
```

### 参数

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

要选择的已保存设备名称（UTF-8）；或者，当 `createIfMissing` 为 false 时，传递 `nullptr` 以清除默认设备。

`createIfMissing`\
类型：**bool**

选择尚未保存的设备时，是否创建一条最小记录。

### 返回值

类型：**HRESULT**

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

## 备注

将 `createIfMissing` 设置为 `true` 可在需要时创建一条最小记录。否则，记录不存在时返回 `WD_E_DEVICE_NOTFOUND`。传递 `nullptr` 和 `false` 可清除默认设备而不移除记录。不要将相互竞争的默认设备更改当作跨进程事务来执行。

已保存设备 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)
- [WdSetDevice](https://docs.xbox.com/zh-CN/reference/remoting/functions/wdsetdevice.md)
- [WdGetDefaultDevice](https://docs.xbox.com/zh-CN/reference/remoting/functions/wdgetdefaultdevice.md)
- [WdSetDeviceProperty](https://docs.xbox.com/zh-CN/reference/remoting/functions/wdsetdeviceproperty.md)
- [IGameInputDevice::SetLightingColor](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setlightingcolor.md)
