I have a Windows service written in C++ that needs to access the clipboard and read data from/paste data to it. I'm considering only textual data.
From MSDN's documentation, I can use OpenClipboard
, EmptyClipboard
and SetClipboardData
to achieve what I want to.
I would have to pass NULL
to OpenClipboard
since I don't have any UI and hence no window handles. However, this would mean -
If an application calls OpenClipboard with hwnd set to NULL, EmptyClipboard sets the clipboard owner to NULL; this causes SetClipboardData to fail.
which would mean I can't set data on the clipboard.
What would be the correct way to get around this problem? Is it possible without using any windows?