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

# WdCreateCancellationHandle

> WdCreateCancellationHandle

# WdCreateCancellationHandle

建立可用來取消由 [WdRemoteCopy](/zh-TW/reference/remoting/functions/wdremotecopy) 啟動之複製作業的取消控制代碼。

## 語法

```cpp theme={null}
HRESULT WdCreateCancellationHandle(  
         _Out_ WdCancellationHandle* cancellationHandle  
);  
```

### 參數

`_Out_ cancellationHandle`\
類型：**[WdCancellationHandle](/zh-TW/reference/remoting/structs/wdcancellationhandle)\***

接收新建立的取消控制代碼。呼叫端負責在不再需要此控制代碼時呼叫 [WdCloseCancellationHandle](/zh-TW/reference/remoting/functions/wdclosecancellationhandle) 加以釋放。

### 傳回值

類型：**HRESULT**

如果成功，則傳回 `S_OK`；否則傳回錯誤碼。

## 備註

在開始複製作業之前呼叫 `WdCreateCancellationHandle`，以取得可啟用取消的控制代碼。透過 `cancellationHandle` 參數將控制代碼傳遞給 [WdRemoteCopy](/zh-TW/reference/remoting/functions/wdremotecopy)，然後從另一個執行緒將它傳遞給 [WdCancelRemoteCopy](/zh-TW/reference/remoting/functions/wdcancelremotecopy) 以取消作業。

`WdRemoteCopy` 傳回之後，請呼叫 [WdCloseCancellationHandle](/zh-TW/reference/remoting/functions/wdclosecancellationhandle) 關閉控制代碼。控制代碼可以在多次 `WdRemoteCopy` 呼叫之間重複使用，但每個控制代碼最終都必須關閉。

## 需求

| 需求 | 值 |
| - | - |
| **標頭** | WdRemoteIteration.h |
| **程式庫** | wdremoteapi.lib |
| **支援的作業系統** | Windows 11 及更新版本 |
| **支援的架構** | x64、ARM64 |

## 另請參閱

* [WdCloseCancellationHandle](/zh-TW/reference/remoting/functions/wdclosecancellationhandle)
* [WdDuplicateCancellationHandle](/zh-TW/reference/remoting/functions/wdduplicatecancellationhandle)
* [WdCancellationHandle](/zh-TW/reference/remoting/structs/wdcancellationhandle)
* [WdRemoteCopy](/zh-TW/reference/remoting/functions/wdremotecopy)
* [WdCancelRemoteCopy](/zh-TW/reference/remoting/functions/wdcancelremotecopy)
* [XBOX PC Remote Iteration API](/zh-TW/reference/remoting/remoteiteration_members)


## Related topics

- [WdCreateCancellationHandle](/reference/remoting/functions/wdcreatecancellationhandle.md)
- [WdCancellationHandle](/reference/remoting/structs/wdcancellationhandle.md)
- [WdCloseCancellationHandle](/reference/remoting/functions/wdclosecancellationhandle.md)
- [WdDuplicateCancellationHandle](/reference/remoting/functions/wdduplicatecancellationhandle.md)
