>It's best to think of these in two parts. The Windows API part and then the
>interfacing with Pascal part.
>SaveAsFileName.lpstrFile = long pointer to a (C) string filename buffer
>This buffer isn't created for you, you provide it and tell Windows it's size.
Thank you for the explanation, that e
on behalf of James
Richters via fpc-pascal
Sent: Monday, June 21, 2021 1:56 PM
To: 'FPC-Pascal users discussions'
Cc: James Richters ; 'Jean SUZINEAU'
Subject: Re: [fpc-pascal] GetSaveFileNameA limited to 100 characters in default
name
>I would prefer to use
> StrPLCo
>I would prefer to use
> StrPLCopy( SaveAsFileNameBuffer, DefaulSaveAsFileName,
SizeOf(SaveAsFileNameBuffer));
>instead of
> SaveAsFileNameBuffer:=Pchar(DefaulSaveAsFileName);
I'm curious what the difference is between StrPLCopy() and PChar()
I wonder if PChar() was my problem.. maybe I don't
I have it working better now.
I was having a crash with Code 216
Appearantly
SaveAsFileName.lpstrFile:= Pchar(DefaulSaveAsFileName);
Just doesn't work the way I want it to. If I try to do the conversion to
Pchar that way, I get an error 216 on:
SaveAsResult:=GetSaveFileNameA(@SaveAsFileNa
>It's curious, I'm not completely sure we are reasoning about the same
function and record.
It seems I should not be using TFilename as the variable name.
I'm usinga variable called TFileName with GetSaveFileNameA()
Here is the relevant code.. after I fixed it to use Max_Path
Uses CRT,CRT.He
Le 21/06/2021 à 03:04, James Richters a écrit :
Var
...
DefaulSaveAsFileName: Ansistring;
SaveAsFileNameBuffer: array[0..Max_Path+1] of char;
...
Begin
DefaulSaveAsFileName := 'X:\Something with a really really really long
long long long file name to see if there is still a bug with
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;
Thi
It's curious, I'm not completely sure we are reasoning about the same
function and record.
You mention TFileName but for me in FPC 3.2.0:
- TFileName is declared as "TFileName= type string;" in sysutilh.inc.
- OPENFILENAMEA is declared as record in CommDlg.pp line 94
and TOPENFILENAMEA=OPEN
>MAX_PATH itself seems to be an alias from system unit where it is defined
accordingly to the operating system (260 on windows, 4096 on Linux, 1024 on
BSD, Solaris and Darwin).
>It's unlikely, but this way you can end up with the corruption of the byte
right after the memory block DefaultFileName
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
I'm not familiar with GetSaveFileNameA, but usually for the size of a
FileName buffer I use the constant MAX_PATH which is defined in unit
SysUtils.
MAX_PATH itself seems to be an alias from system unit where it is
defined accordingly to the operating system (260 on windows, 4096 on
Linux, 1
I'm converting my AnsiString to a Pchar with
TFileName.lpstrFile:=Pchar(DefaultFileName);
But I didn't understand the meaning of
TFileName.nMaxFile:=100; I thought it was the maximum number of files to
display or something.. not the maximum number of characters in the file
name. which it appea
The Windows API doesn't understand what an 'AnsiString' is and cannot resize it
dynamically like FreePascal would do as it is used.
You need to use something like
buf: array[0..512] of char;
TFileName.nMaxFile := sizeof(buf);
But then you should also handle the possibility that the dir is grea
13 matches
Mail list logo