in reply to Re: Win32::Clipboard and Unicode
in thread Win32::Clipboard and Unicode
Where can I find the source code for the current/latest version of Win32::Clipboard? (I have ActiveState Perl, which is a binary distribution. Their "source code" download AP806_source.zip doesn't contain any file named Clipboard.*)
The MS API GetClipboardData provides no way to get the length of the data returned. Quite an unfortunate design.
Hmm, it actually returns a HANDLE to a global memory block, which is as far as I can tell the only remaining use for such a thing. In Win32 HGLOBAL's have been replaced by normal memory pointers and the documentation mostly missing.
Anyway, the Win32 function GlobalSize will return the length. Do that before copying via memcpy what GlobalLock returns, instead of using a strcpy. However, it also says, “The size of a memory block may be larger than the size requested when the memory was allocated.” so perhaps this shows the rounded-up capacity, not the requested size.
If a function returned a pointer like you suggest, rather than copying it, how will Perl know to free it eventually?
To find the bytes 00 00, why not use a regex instead of a eq substr? /.*?\0\0/ or somesuch.
—John
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Win32::Clipboard and Unicode
by tye (Sage) on Apr 22, 2003 at 20:56 UTC | |
by John M. Dlugosz (Monsignor) on Apr 22, 2003 at 21:14 UTC |