Thank you for the help. I always seem to have difficulties understanding how to interface with windows functions. I did see the msdn help.. to me it seemed that lpszFormatName was the LPTSTR variable that would contain the name, but that's not what is being passed to it at all... it's a POINTER to the variable, the docs never said it was a pointer.
This is what it shows and how I understood it: int GetClipboardFormatNameA( UINT format, // an Unsigned Integer Variable LPSTR lpszFormatName, // an LPSTR Variable which I understand is just a PChar int cchMaxCount // an Integer Variable ); There is just nothing anywhere that indicated to me that lpszFormatName was a pointer to a variable. If they were expecting a pointer, then I would think it would be shown something like this: int GetClipboardFormatNameA( UINT format, Pointer to lpszFormatName, int cchMaxCount ); Anyway, THANKS for straightening me out on this! I have it mostly working but when I try to use Move() I end up missing the first character of the format name. I assume you mentioned using UniqueString() to fix this, but I don't know how to apply it. Here is what I have now: Var FN : Array[0..255] of Byte; Format_Name, Format_Name_Move : String; ... Name_Length:=GetClipboardFormatName(Format_Id,LPTSTR(@FN[0]),255); If Name_Length >0 Then Begin Format_Name:=''; For k:= 0 to Name_Length-1 Do Format_Name:=Format_Name+Chr(FN[k]); Move(FN,Format_Name_Move,Name_Length); End; Writeln(Format_ID,'|',Name_Length,'|',Format_Name,'|',Format_Name_Move); ... Here is the Output, you can see that my loop gets the entire name, but the Move() is missing the first letter.. I:\Programming\Gcode\Test>"Clipboard Formats.exe" Number of formats: 6 13 CF_UNICODETEXT 49963|17|MSDEVColumnSelect|SDEVColumnSelect 49964|22|Borland IDE Block Type|orland IDE Block Type 16 CF_LOCALE 1 CF_TEXT 7 CF_OEMTEXT James -----Original Message----- From: fpc-pascal <fpc-pascal-boun...@lists.freepascal.org> On Behalf Of Martin Frb via fpc-pascal Sent: Wednesday, December 30, 2020 8:00 PM To: fpc-pascal@lists.freepascal.org Cc: Martin Frb <laza...@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@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal