On the official Microsoft docs for EmptyClipboard, it says that EmptyClipboard should cause SetClipboardData to fail when a NULL window handle is used for OpenClipboard. However this doesn't seem to be the case at all, so what's going on? In fact, SetClipboardData doesn't work when I don't call EmptyClipboard, and every stackoverflow post on it says to call EmptyClipboard before SetClipboardData.
https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-emptyclipboard (Under Remarks)
Before calling EmptyClipboard, an application must open the clipboard by using the OpenClipboard function. If the application specifies a NULL window handle when opening the clipboard, EmptyClipboard succeeds but sets the clipboard owner to NULL. Note that this causes SetClipboardData to fail.
Many stackoverflow posts saying to do exactly what Microsoft says should fail (with success!):