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 ...


_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to