> ## 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-TW/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-TW/reference/remoting/error-codes.md)中所述的目錄特有錯誤。

## 備註

將 `createIfMissing` 設定為 `true`，即可在需要時建立最基本的記錄。否則，找不到記錄時會傳回 `WD_E_DEVICE_NOTFOUND`。傳遞 `nullptr` 和 `false` 可清除預設值而不移除記錄。請勿將相互競爭的預設值變更當成跨處理序交易來發出。

已儲存裝置 API 和配對識別碼 API 會變更不同的本機存放區。它們不會取代遠端 API 呼叫中明確的 `remoteDevice` 引數；想要使用預設選取的呼叫端必須自行解析。

## 需求

| 需求 | 值 |
| - | - |
| **標頭** | WdRemoteIteration.h |
| **程式庫** | wdremoteapi.lib |
| **NuGet 套件** | [Microsoft.GDK.RemoteIterationClientApi](https://aka.ms/GameDevRemoteAPI) |

## 另請參閱

* [XBOX PC Remote Iteration API](https://docs.xbox.com/zh-TW/reference/remoting/remoteiteration_members.md)


## Related topics

- [XBOX PC Remote Iteration API](https://docs.xbox.com/zh-TW/reference/remoting/remoteiteration_members.md)
- [WdSetDevice](https://docs.xbox.com/zh-TW/reference/remoting/functions/wdsetdevice.md)
- [WdGetDefaultDevice](https://docs.xbox.com/zh-TW/reference/remoting/functions/wdgetdefaultdevice.md)
- [WdSetDeviceProperty](https://docs.xbox.com/zh-TW/reference/remoting/functions/wdsetdeviceproperty.md)
- [IGameInputDevice::SetLightingColor](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_setlightingcolor.md)
