This Question have 3 answers right now.

Why would the Win32 OleGetClipboard() function return CLIPBRD_E_CANT_OPEN?

Question!

Under what circumstances will the Win32 API function OleGetClipboard() fail and return CLIPBRD_E_CANT_OPEN?

More background: I am assisting with a Firefox bug fix. Details here:

bug 444800 - cannot retrieve image data from clipboard in lossless format

In the automated test that I helped write, we see that OleGetClipboard() sometimes fails and returns CLIPBRD_E_CANT_OPEN. That is unexpected, and the Firefox code to pull image data off the Windows clipboard depends on that call succeeding.

By : user21968


Answers

The documentation says that OleGetClipboard can fail with this error code if OpenClipboard fails. In turn, if you read that documentation, it says:

"OpenClipboard fails if another window has the clipboard open."

It's an exclusive resource: only one window can have the clipboard open at a time. Basically, if you can't do it, wait a little while and try again.



From what I see in MSDN it seems to imply that the problem originates with whomever tried to actually put the data in the clipboard, i,.e. the source of the data. If their call to OleSetClipboard() failed, for whatever reason, then you won't be able to extract stuff out. I would take a look at how the data is being put into the clipboard, and see if there's a test case that performs this (copying the data to the clipboard), and then causes the problem you're talking about.



Is your test running over Terminal Services? See CLIPBRD_E_CANT_OPEN error when setting the Clipboard from .NET.

By : Tadmas


Video about Why would the Win32 OleGetClipboard() function return CLIPBRD_E_CANT_OPEN?