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

# WdCreateCancellationHandle

> WdCreateCancellationHandle

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

## Syntax

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

### Parameters

`_Out_ cancellationHandle`\
Type: **[WdCancellationHandle](https://docs.xbox.com/reference/remoting/structs/wdcancellationhandle.md)\***

Receives the newly created cancellation handle. The caller is responsible for freeing this handle by calling [WdCloseCancellationHandle](https://docs.xbox.com/reference/remoting/functions/wdclosecancellationhandle.md) 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](https://docs.xbox.com/reference/remoting/functions/wdremotecopy.md) via the `cancellationHandle` parameter, and then pass it to [WdCancelRemoteCopy](https://docs.xbox.com/reference/remoting/functions/wdcancelremotecopy.md) from a separate thread to cancel the operation.

After `WdRemoteCopy` returns, close the handle by calling [WdCloseCancellationHandle](https://docs.xbox.com/reference/remoting/functions/wdclosecancellationhandle.md). 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](https://docs.xbox.com/reference/remoting/functions/wdclosecancellationhandle.md)
* [WdDuplicateCancellationHandle](https://docs.xbox.com/reference/remoting/functions/wdduplicatecancellationhandle.md)
* [WdCancellationHandle](https://docs.xbox.com/reference/remoting/structs/wdcancellationhandle.md)
* [WdRemoteCopy](https://docs.xbox.com/reference/remoting/functions/wdremotecopy.md)
* [WdCancelRemoteCopy](https://docs.xbox.com/reference/remoting/functions/wdcancelremotecopy.md)
* [XBOX PC Remote Iteration API](https://docs.xbox.com/reference/remoting/remoteiteration_members.md)


## Related topics

- [WdCancellationHandle](https://docs.xbox.com/reference/remoting/structs/wdcancellationhandle.md)
- [WdCloseCancellationHandle](https://docs.xbox.com/reference/remoting/functions/wdclosecancellationhandle.md)
- [WdDuplicateCancellationHandle](https://docs.xbox.com/reference/remoting/functions/wdduplicatecancellationhandle.md)
- [WdCancelRemoteDelete](https://docs.xbox.com/reference/remoting/functions/wdcancelremotedelete.md)
- [WdCancelRemoteCopy](https://docs.xbox.com/reference/remoting/functions/wdcancelremotecopy.md)
