[fpc-pascal] GetSaveFileNameA limited to 100 characters in default name

Jean SUZINEAU jean.suzineau at wanadoo.fr
Sat Jun 19 01:24:17 CEST 2021


I haven't seen your reply.
Le 18/06/2021 à 23:50, James Richters via fpc-pascal a écrit :
> So now I have:
>
> TFileName.nMaxFile:= Length(DefaultFileName)+1;
>
> TFileName.lpstrFile:=Pchar(DefaultFileName);
>
> I need the +1 for the #0 at the end of the Pchar, and now it works 
> fine, and I can have strings as long as they need to be.
>
I think that this way you tell GetSaveFileNameA that it can write 
Length(DefaultFileName)+1 chars in Pchar(DefaultFileName),
but you have only allocated Length(DefaultFileName) chars to 
DefaultFileName .

It's unlikely, but this way you can end up with the corruption of the 
byte right  after the memory block DefaultFileName is pointing to ...


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20210619/07e01b4c/attachment-0001.htm>


More information about the fpc-pascal mailing list