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

Creates a cancellation handle that can be used to cancel a copy operation started by [WdRemoteCopy](/reference/remoting/functions/wdremotecopy).

## Syntax

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

### Parameters

`_Out_ cancellationHandle`\
Type: **[WdCancellationHandle](/reference/remoting/structs/wdcancellationhandle)\***

Receives the newly created cancellation handle. The caller is responsible for freeing this handle by calling [WdCloseCancellationHandle](/reference/remoting/functions/wdclosecancellationhandle) when it is no longer needed.

### Return value

Type: **HRESULT**

Returns `S_OK` if successful; otherwise, returns an error code.

## Remarks

Call `WdCreateCancellationHandle` before starting a copy operation to obtain a handle that enables cancellation. Pass the handle to [WdRemoteCopy](/reference/remoting/functions/wdremotecopy) via the `cancellationHandle` parameter, and then pass it to [WdCancelRemoteCopy](/reference/remoting/functions/wdcancelremotecopy) from a separate thread to cancel the operation.

After `WdRemoteCopy` returns, close the handle by calling [WdCloseCancellationHandle](/reference/remoting/functions/wdclosecancellationhandle). The handle can be reused across multiple `WdRemoteCopy` calls, but each handle must eventually be closed.

## Requirements

| Requirement                 | Value                |
| --------------------------- | -------------------- |
| **Header**                  | WdRemoteIteration.h  |
| **Library**                 | wdremoteapi.lib      |
| **Supported OS**            | Windows 11 and later |
| **Supported architectures** | x64, ARM64           |

## See also

* [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 Remote Iteration API](/reference/remoting/remoteiteration_members)


## Related topics

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