views:

40

answers:

2

I have an app which, long story short, uses the clipboard for part of its operation.

Sometimes though, for reasons I've never 100% nailed down, sometimes the clipboard isn't available. Sometimes the RDC client blocks it, sometimes it doesn't. And it's one of those extremely hard to reproduce when you really need to sorts of deals.

Could one write a little testing program that, while it runs, doesn't allow any other programs to access the clipboard?

+1  A: 

I suppose you could call OpenClipboard, and EmptyClipboard, then simply keep it open and only call CloseClipboard when the testing application exits, or something like that...

EDIT FROM SCHNAPPLE

So this is what I did essentially and I found C# code to do it on... that other site

[ DllImport( "user32.dll" ) ]
extern static bool OpenClipboard( IntPtr hWnd );

[ DllImport( "user32.dll" ) ]
extern static bool CloseClipboard();

[ DllImport( "user32.dll" ) ]
extern static IntPtr GetClipboardData( uint uFormat );

public static void GetSomeDib()
{
      OpenClipboard( System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle );

      IntPtr img = GetClipboardData(8);

      MessageBox.Show("Clipboard Locked");

      CloseClipboard();

      MessageBox.Show("Clipboard Unlocked");
}
Jerry Coffin
A: 

The easy solution may be to just manually configure RemDesk to not monitor the clipboard. It's an option in RemDesk... But yes, keeping the clipboard open should have the desired effect, and will also keep WM_DrawClipboard notifications from being sent to clipboard viewers.

Chris Thornton