[fpc-pascal] GetClipboardFormatName causing an Error 216

Alexander Grotewohl alex at dcclost.com
Thu Dec 31 02:03:58 CET 2020


The memory for FN is allocated at the top with StrAlloc()

--
Alexander Grotewohl
https://dcclost.com
________________________________
From: fpc-pascal <fpc-pascal-bounces at lists.freepascal.org> on behalf of Martin Frb via fpc-pascal <fpc-pascal at lists.freepascal.org>
Sent: Wednesday, December 30, 2020 8:00 PM
To: fpc-pascal at lists.freepascal.org <fpc-pascal at lists.freepascal.org>
Cc: Martin Frb <lazarus at mfriebe.de>
Subject: Re: [fpc-pascal] GetClipboardFormatName causing an Error 216

On 31/12/2020 01:09, James Richters via fpc-pascal wrote:
> Var
>     FN : LPTSTR;
>
> Begin
>
>                 FN:='';
>                 Writeln(Format_ID);
>                 GetClipboardFormatName(Format_Id,FN,250);
>

Check the msdn help.
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclipboardformatnamea

FN must point to an existing buffer (allocated mem) that receives the
result.

FN : Array [0..255]of Byte;
GotLen := GetClipboardFormatName(Format_Id, LPTSTR(@FN[0]),250);

then "move()" the received bytes into a string, make sure to use
UniqueString() or similar

_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20201231/ae9446a9/attachment.htm>


More information about the fpc-pascal mailing list