I am writing a test app for a larger project and cant seem to retrieve Unicode CSV data from the Windows Clipboard, I am successful at retrieving CF_UNICODETEXT, using the built in GetClipboardData api call, however when I place Unicode CSV on the clipboard in MSExcel and try to retrieve with CSV format, I get bad data. Here is some code;
procedure TForm1.Button7Click(Sender: TObject);
var
hMem : THandle;
dwLen : DWord;
ps1, ps2 : pChar;
begin
OpenClipboard( form1.Handle );
RichEdit1.Lines.Clear;
try
if Clipboard.HasFormat( CF_UNICODETEXT ) then
begin
hMem := GetClipboardData( CF_UNICODETEXT );
ps1 := GlobalLock( hMem );
dwLen := GlobalSize( hMem );
ps2 := StrAlloc( 1 + dwLen );
StrLCopy( ps2, ps1, dwLen );
GlobalUnlock( hMem );
RichEdit1.Lines.Add( ps2 );
end
else
ShowMessage( 'No CF_UNICODETEXT on Clipboard!' );
finally
CloseClipboard;
end;
end;
Now this code should work for CSV as well, but when I change my Clipboard format to what I'm desiring, the app will not get proper data. It might be important to know that I can get tabbed Unicode just fine, just not he CSV I desire.