> ## 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-TW/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\***

以 UTF-8 編碼的已儲存裝置名稱或 IP 位址。此作業會作用於目前使用者的本機目錄。

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

最後觀察到的配對裝置識別碼，或傳遞 `nullptr` 以清除它。此值並非授權。

### 傳回值

類型：**HRESULT**

成功時傳回 `S_OK`；否則傳回失敗 HRESULT。目錄作業也會傳回[錯誤碼](https://docs.xbox.com/zh-TW/reference/remoting/error-codes.md)中所述的目錄特有錯誤。

## 備註

保留應用程式擁有的中繼資料。在空的目錄中記錄的第一個裝置會成為預設裝置。`publicKeyHash` 是最後觀察到的 40 個字元十六進位配對裝置識別碼；傳遞 `nullptr` 可清除它。空白或格式不正確的雜湊會傳回 `E_INVALIDARG`。

儲存記錄不會配對裝置、驗證其目前的身分識別，也不會授與存取權。

已儲存裝置 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)
- [WdSetDeviceProperty](https://docs.xbox.com/zh-TW/reference/remoting/functions/wdsetdeviceproperty.md)
- [WdSetDefaultDevice](https://docs.xbox.com/zh-TW/reference/remoting/functions/wdsetdefaultdevice.md)
- [WdEnumDevices](https://docs.xbox.com/zh-TW/reference/remoting/functions/wdenumdevices.md)
- [WdGetDevice](https://docs.xbox.com/zh-TW/reference/remoting/functions/wdgetdevice.md)
