| Previous | Next |
| CLIPBRD_E_CANT_OPEN | CLIPBRD_E_CANT_SET |
CLIPBRD_E_CANT_EMPTY
EmptyClipboard Failed
When Windows returns CLIPBRD_E_CANT_EMPTY—HRESULT 2147746257, 0x800401D1, signed -2147221039—AllStat describes the condition as “EmptyClipboard Failed”. The actionable meaning is EmptyClipboard failed after the application attempted to take clipboard ownership. The surrounding operation is clearing existing formats before publishing new clipboard data.
The high bit in 0x800401D1 is set, so this is a failure rather than a success or informational result. Its facility field is 4 (FACILITY_ITF) and its low 16-bit code is 465 (0x01D1). Those bit fields classify the value, but they do not identify the failing object by themselves; the native method, object identity, and first producer of CLIPBRD_E_CANT_EMPTY remain essential.
Precise failure point
Understanding CLIPBRD_E_CANT_EMPTY requires this subsystem context: The Win32 clipboard is a short ownership transaction with format-specific handle semantics. For CLIPBRD_E_CANT_EMPTY, logging only a final HRESULT loses whether the failure happened while opening, emptying, publishing, or later consuming data.
- Associate
CLIPBRD_E_CANT_EMPTYwith one exact operation in OpenClipboard, EmptyClipboard, SetClipboardData, format-specific handle rules, delayed rendering, and clipboard ownership. - Confirm that
CLIPBRD_E_CANT_EMPTYcame from clearing existing formats before publishing new clipboard data, rather than from cleanup or a wrapper that ran afterward. - Preserve any IErrorInfo, underlying Win32 result, provider message, or callback failure that preceded
CLIPBRD_E_CANT_EMPTY; the HRESULT alone should not erase a more specific cause.
Diagnostic evidence
A useful CLIPBRD_E_CANT_EMPTY incident records the clipboard opener HWND, owner HWND, sequence number, format ID and name, handle type, allocation flags, delayed-rendering choice, last-error value, and thread or message-loop state. For CLIPBRD_E_CANT_EMPTY, also retain the application and component build, architecture, process and thread IDs, COM apartment, operation correlation ID, elapsed time, and the first state-changing event before the failure. When logging CLIPBRD_E_CANT_EMPTY, redact content and credentials while preserving types, lengths, hashes, opaque identities, and lifecycle generations needed to reproduce its contract.
- For
CLIPBRD_E_CANT_EMPTY, record OpenClipboard success, opener HWND, owner HWND, sequence number, and GetLastError. - For
CLIPBRD_E_CANT_EMPTY, keep the clipboard open only for the minimal transaction. - For
CLIPBRD_E_CANT_EMPTY, trace reentrant clipboard viewers, delayed-render callbacks, and message handling.
Resolution path
- Capture
CLIPBRD_E_CANT_EMPTYat the first native return before a wrapper maps it to a generic exception. - Identify the exact object, method, and lifecycle phase involved in clearing existing formats before publishing new clipboard data.
- Record OpenClipboard success, opener HWND, owner HWND, sequence number, and GetLastError.
- Keep the clipboard open only for the minimal transaction.
- Trace reentrant clipboard viewers, delayed-render callbacks, and message handling.
- Reproduce
CLIPBRD_E_CANT_EMPTYwith one controlled input or state change, and verify that the correction changes the decisive evidence rather than merely hiding the result.
Distinct causes
CLIPBRD_E_CANT_EMPTYcan result when the application has not successfully opened the clipboard.CLIPBRD_E_CANT_EMPTYcan result when the clipboard opener/owner sequence is invalid for the supplied HWND.CLIPBRD_E_CANT_EMPTYcan result when another component or reentrant message path changes clipboard state during the operation.
Retry policy
Correction. For CLIPBRD_E_CANT_EMPTY, close any failed transaction, wait briefly for contention, reopen with a valid owner window, empty once, then publish all formats. Retry boundary. Bounded retry is acceptable for confirmed contention, but never spin while holding UI locks or the clipboard itself. Before repeating the CLIPBRD_E_CANT_EMPTY operation, close the clipboard on every path, determine whether EmptyClipboard changed ownership, and never free a handle successfully transferred to the system.
Practical scenario
A worker thread opens the clipboard with a null HWND, empties it, and then cannot set data because ownership is null; performing the transaction on a UI window fixes the sequence. This isolates CLIPBRD_E_CANT_EMPTY within Win32 clipboard ownership and data publication and provides a regression test for the stated correction.
Difference from related HRESULTs
CLIPBRD_E_CANT_SET occurs while publishing a format; CLIPBRD_E_CANT_EMPTY occurs earlier while replacing clipboard ownership and contents. For CLIPBRD_E_CANT_EMPTY, keep those outcomes separate in exception mappings, telemetry dimensions, user messages, and automated retry policy.
Developer and administrator guidance
For CLIPBRD_E_CANT_EMPTY, serialize the open-empty-publish-close transaction, use the documented handle type for each format, and retain delayed-rendering ownership until WM_RENDERFORMAT handling completes. Regression coverage for CLIPBRD_E_CANT_EMPTY should include clipboard contention, owner-window destruction, invalid handle types, delayed rendering, empty data, multiple formats, and failure after ownership has changed.
Operational repair for CLIPBRD_E_CANT_EMPTY must target the evidence-backed owner: identify the process holding or publishing the clipboard and reproduce without clipboard managers or remote-session redirection before changing system configuration. Retain before-and-after traces for CLIPBRD_E_CANT_EMPTY so the change can be attributed and reversed.
References
- Microsoft: generic COM error codes — official Microsoft documentation relevant to
CLIPBRD_E_CANT_EMPTY. - Microsoft: HRESULT values — official Microsoft documentation relevant to
CLIPBRD_E_CANT_EMPTY. - Microsoft: EmptyClipboard — official Microsoft documentation relevant to
CLIPBRD_E_CANT_EMPTY. - Microsoft: SetClipboardData — official Microsoft documentation relevant to
CLIPBRD_E_CANT_EMPTY. - Microsoft: using the clipboard — official Microsoft documentation relevant to
CLIPBRD_E_CANT_EMPTY.
Looking for a different code? Search another status or error code.