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

2021-06-21 Thread James Richters via fpc-pascal
>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

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

2021-06-21 Thread Alexander Grotewohl via fpc-pascal
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 > StrPLCopy( SaveAsFileNameBuffer, DefaulSaveAsFi

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

2021-06-21 Thread James Richters via fpc-pascal
>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

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

2021-06-21 Thread James Richters via fpc-pascal
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:

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

2021-06-21 Thread James Richters via fpc-pascal
>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

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

2021-06-20 Thread Jean SUZINEAU via fpc-pascal
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

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

2021-06-19 Thread Jean SUZINEAU via fpc-pascal
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;

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

2021-06-19 Thread Jean SUZINEAU via fpc-pascal
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

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

2021-06-18 Thread James Richters via fpc-pascal
>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

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

2021-06-18 Thread Jean SUZINEAU via fpc-pascal
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

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

2021-06-18 Thread Jean SUZINEAU via fpc-pascal
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,

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

2021-06-18 Thread James Richters via fpc-pascal
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

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

2021-06-18 Thread Alexander Grotewohl via fpc-pascal
-Pascal users discussions' Cc: James Richters Subject: [fpc-pascal] GetSaveFileNameA limited to 100 characters in default name I’m using GetSaveFileNameA() in a windows console program to obtain a save-as directory and file name, I am passing sending it a default file name

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

2021-06-18 Thread James Richters via fpc-pascal
I'm using GetSaveFileNameA() in a windows console program to obtain a save-as directory and file name, I am passing sending it a default file name with: TFileName.lpstrFile:=Pchar(DefaultFileName); DefaultFileName is an AnsiString that contains a full path and filename. This all works fine