<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The memory for FN is allocated at the top with StrAlloc()</div>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="Signature">
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
--</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Alexander Grotewohl</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
https://dcclost.com</div>
</div>
</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> fpc-pascal <fpc-pascal-bounces@lists.freepascal.org> on behalf of Martin Frb via fpc-pascal <fpc-pascal@lists.freepascal.org><br>
<b>Sent:</b> Wednesday, December 30, 2020 8:00 PM<br>
<b>To:</b> fpc-pascal@lists.freepascal.org <fpc-pascal@lists.freepascal.org><br>
<b>Cc:</b> Martin Frb <lazarus@mfriebe.de><br>
<b>Subject:</b> Re: [fpc-pascal] GetClipboardFormatName causing an Error 216</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On 31/12/2020 01:09, James Richters via fpc-pascal wrote:<br>
> Var<br>
>     FN : LPTSTR;<br>
><br>
> Begin<br>
><br>
>                 FN:='';<br>
>                 Writeln(Format_ID);<br>
>                 GetClipboardFormatName(Format_Id,FN,250);<br>
><br>
<br>
Check the msdn help.<br>
<a href="https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclipboardformatnamea">https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclipboardformatnamea</a><br>
<br>
FN must point to an existing buffer (allocated mem) that receives the <br>
result.<br>
<br>
FN : Array [0..255]of Byte;<br>
GotLen := GetClipboardFormatName(Format_Id, LPTSTR(@FN[0]),250);<br>
<br>
then "move()" the received bytes into a string, make sure to use <br>
UniqueString() or similar<br>
<br>
_______________________________________________<br>
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org<br>
<a href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a><br>
</div>
</span></font></div>
</body>
</html>