Clipboard help

I am trying to read data from the clipboard. I want to be able to read it in ANY format. I have basicly figured out how to do that, but I am haveing some problems. I am useing GlobalSize() to get the size of the memory block allocated for the clipboard. This works fine most of the time, however sometimes (like with files copied from windows explorer) it returns a value that is *LESS* than the size it should be. Any ideas of why this would be happening or a better way to get the size of the memory block allocated to the clipboard?

Comments

: This works fine most of the time, however sometimes (like with files copied from windows explorer) it returns a value that is *LESS* than the size it should be.

Have you tried dumping the data (to a file, for example) to see what it is? Files copied from Windows Explorer are not stored as content, but merely their filename (and half a dozen OLE drag-drop formats).-- [italic][blue]Sunlight[/blue][/italic]

: : This works fine most of the time, however sometimes (like with files copied from windows explorer) it returns a value that is *LESS* than the size it should be.: : Have you tried dumping the data (to a file, for example) to see what it is? Files copied from Windows Explorer are not stored as content, but merely their filename (and half a dozen OLE drag-drop formats).: -- : [italic][blue]Sunlight[/blue][/italic]: :

I realize that the actual file is not copied to the clipboard. The GlobalSize function returns 32 for the size of clipboard items that are copied from windows explorer. I have tried dumping the data (the 32 bytes) that I get from the clipboard into a file, but it is not complete. I know that it is not complete because I used the clipboard viewer to save the clipboard to a .clp file, and then used a hex editor to search the .clp file for the values that were at the beginning of the file that I dumped from my program. I searched the .clp file for these values and found them after what I assume is the header to the .clp file, but there is more data after the 32 bytes that my program reads. The data after those 32 bytes contains the file path and name. This is why I assume it is a problem in reading size of the clipboard memory.

The program that I am writing is supposed to be able to copy the contents of the clipboard and put them back on the clipboard, and it works fine with other clipboard data. I think it would work fine for th "files" copied from windows explorer also if I could read all the data.

The program is eventually going to allow you to store the last however many number of clipboard "clips" and restore them back onto the clipboard. There are other programs that do this or something similar...

: I have tried dumping the data (the 32 bytes) that I get from the clipboard into a file, but it is not complete.

Which format are you reading? You pass a clipboard format to GetClipboardData; the shell puts eight of them on there, which you can enumerate using EnumClipboardFormats.

: The program is eventually going to allow you to store the last however many number of clipboard "clips" and restore them back onto the clipboard. There are other programs that do this or something similar...

ClipBook (which I think is now the standard Clipboard Viewer) allows you to do just this, as does Office 2000.-- [italic][blue]Sunlight[/blue][/italic]

: : I have tried dumping the data (the 32 bytes) that I get from the clipboard into a file, but it is not complete. : : Which format are you reading? You pass a clipboard format to GetClipboardData; the shell puts eight of them on there, which you can enumerate using EnumClipboardFormats.: : : The program is eventually going to allow you to store the last however many number of clipboard "clips" and restore them back onto the clipboard. There are other programs that do this or something similar...: : ClipBook (which I think is now the standard Clipboard Viewer) allows you to do just this, as does Office 2000.: -- : [italic][blue]Sunlight[/blue][/italic]: :

I was reading/writing it in the first format that I got from EnumClipboardFormats() (I believe it was the DataObject format), that could be the problem I suppose, I think I will try reading/writing it in other formats... and see how that works