Bypass Clipboard History in the Windows 10 October 2018 Update

Viewed 1209

We have a C++ app the makes heavy use of the clipboard API OpenClipboard etc.

The app is frequently saving the contents of the clipboard, inserting content, pasting and then restoring the clipboard.

With the Windows 10 October update this is causing a lot of Clipboard History that may also be synced between devices.

Is there a new api to bypass the new clipboard history?

1 Answers

Finally found a way to do this - supported by microsoft and finally documented here: Cloud Clipboard and Clipboard History Formats

You need to get a couple of format ids first

UINT clipboardHistoryFormat_ = RegisterClipboardFormat(L"CanIncludeInClipboardHistory");
UINT cloudClipboardFormat_ = RegisterClipboardFormat(L"CanUploadToCloudClipboard");

Then when you write anything to the clipboard that you don't want in the Windows 10 History or Cloud you then need to also set the above formats with a DWORD value of 0

auto number_of_bytes = sizeof(DWORD);
auto hMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, number_of_bytes);
if (hMem != nullptr)
{
    if (SetClipboardData(clipboardHistoryFormat_, hMem) == nullptr)
    {
        // something went wrong
    }
}
Related