How to get Unicode CSV MS Windows XP clipboard data?

I am writing a test application for a larger project and it seems that I am not getting Unicode CSV data from the Windows clipboard, I manage to get CF_UNICODETEXT using the built-in GetClipboardData api call, however, when I put Unicode CSV to the clipboard in MSExcel and try to get in the format CSV, I get bad data. Here is the 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 too, but when I change the clipboard format to what I want, the application will not receive the correct data. Perhaps it’s important to know that I can get the Unicode tab just fine, it’s just not the CSV that I want.

+3
source share
2

CSV Excel ANSI, .

Excel 2007, Unicode:

  • CF_UNICODETEXT
  • " HTML"
  • " Rich Text"
  • "XML-"

"XML-" " HTML" /, .

+4

CF_CSV. , CF_CSV, AnsiString, UnicodeString, .

, 6 , Excel2007. ClipMate CF_CSV, hexMate ClipMate. , ( 2C), CRLF (x0Dx0A). , Excel, ClipMate- CF_CSV . alt text
(: thornsoft.com)

, : CSV ( Excel),

+1

Source: https://habr.com/ru/post/1751061/


All Articles