[fpc-pascal] GetSaveFileNameA limited to 100 characters in default name
Jean SUZINEAU
jean.suzineau at wanadoo.fr
Sun Jun 20 05:35:46 CEST 2021
I think you should have a look at this documentation on strings,
particularly for PChar :
https://www.freepascal.org/docs-html/ref/refsu9.html
Le 20/06/2021 à 02:09, James Richters a écrit :
> DefaultFileName: AnsiString = '' ;
So Length(DefaultFileName) = 0
> TFileName.nMaxFile:=Max_Path+1;
This says that lpstrFile points to a buffer of size Max_Path+1.
>
> TFileName.lpstrFile:=Pchar('');
>
But here you make it point to a buffer of size 1 (a constant with just a
null char)
>
> TFileName.Flags:= OFN_EXPLORER or OFN_FILEMUSTEXIST or OFN_HIDEREADONLY;
>
I think OFN_FILEMUSTEXIST forbid to create new file.
>
> TFileName.lpstrFile:=Pchar(DefaultFileName);
New assignment of lpstrFile, make it point to DefaultFileName, which
seems to be of length 0, so a buffer of size 1 (a constant with just a
null char at the end).
I think you should at least add the begining of your code : SetLength(
DefaultFileName, Max_Path);
> It seems TFileName is already defined and I am re-defining
> it…TFileName was not my idea.. that is not how I name my variables…
The name is a bit misleading, but as soon as it's a variable of type
TOpenFileNameA, it's fine.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20210620/bd209260/attachment-0001.htm>
More information about the fpc-pascal
mailing list