> ## 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](/reference/remoting/functions/wdremotecopy) 启动的复制操作。

## 语法

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

### 参数

`_Out_ cancellationHandle`\
类型：**[WdCancellationHandle](/reference/remoting/structs/wdcancellationhandle)\***

接收新创建的取消句柄。调用方负责在不再需要时通过调用 [WdCloseCancellationHandle](/reference/remoting/functions/wdclosecancellationhandle) 来释放该句柄。

### 返回值

类型：**HRESULT**

如果成功，则返回 `S_OK`；否则，返回错误代码。

## 备注

在启动复制操作之前调用 `WdCreateCancellationHandle` 以获取用于实现取消功能的句柄。将该句柄通过 `cancellationHandle` 参数传递给 [WdRemoteCopy](/reference/remoting/functions/wdremotecopy)，然后从单独的线程将其传递给 [WdCancelRemoteCopy](/reference/remoting/functions/wdcancelremotecopy) 以取消操作。

在 `WdRemoteCopy` 返回后，通过调用 [WdCloseCancellationHandle](/reference/remoting/functions/wdclosecancellationhandle) 关闭句柄。该句柄可在多次 `WdRemoteCopy` 调用之间重复使用，但每个句柄最终都必须被关闭。

## 要求

| 要求          | 值                   |
| ----------- | ------------------- |
| **头文件**     | WdRemoteIteration.h |
| **库**       | wdremoteapi.lib     |
| **支持的操作系统** | Windows 11 及更高版本    |
| **支持的体系结构** | x64、ARM64           |

## 另请参阅

* [WdCloseCancellationHandle](/reference/remoting/functions/wdclosecancellationhandle)
* [WdDuplicateCancellationHandle](/reference/remoting/functions/wdduplicatecancellationhandle)
* [WdCancellationHandle](/reference/remoting/structs/wdcancellationhandle)
* [WdRemoteCopy](/reference/remoting/functions/wdremotecopy)
* [WdCancelRemoteCopy](/reference/remoting/functions/wdcancelremotecopy)
* [XBOX PC 远程迭代 API](/reference/remoting/remoteiteration_members)


## Related topics

- [WdCancellationHandle](/zh-CN/reference/remoting/structs/wdcancellationhandle.md)
- [WdCloseCancellationHandle](/zh-CN/reference/remoting/functions/wdclosecancellationhandle.md)
- [WdDuplicateCancellationHandle](/zh-CN/reference/remoting/functions/wdduplicatecancellationhandle.md)
- [WdCancelRemoteCopy](/zh-CN/reference/remoting/functions/wdcancelremotecopy.md)
- [WdRemoteCopy](/zh-CN/reference/remoting/functions/wdremotecopy.md)
