ProgramParameter(), max length

Windows specific forum
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

ProgramParameter(), max length

Post by horst »

When a command parameter has the length of #MAX_PATH (i.e. 259 bytes plus zero-byte) and is enclosed in quote marks, it will be mutilated. Up to 257 bytes is ok.

Maybe the PB internal buffer that receives the command parameter is not large enough to hold the extra quote marks ???
Horst.
maw

Post by maw »

Ehh? MAX_PATH is 255 chars + ending zero...
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

maw wrote:Ehh? MAX_PATH is 255 chars + ending zero...

Code: Select all

Debug #MAX_PATH
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
maw

Post by maw »

Damn.. I could have sworn that MAX_PATH was defined as 256.. Oh well, never mind me then :shock:
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

It should still be possible to use parameters longer than MAX_PATH.
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

Post by horst »

Trond wrote:It should still be possible to use parameters longer than MAX_PATH.
That's a different request.
I just want to use a path parameter with a length up to MAX_PATH (not including the quote marks).
Horst.
Fred
Administrator
Administrator
Posts: 18360
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

I just tried, but can't see the limit. Can anyone else confirm ?

Code: Select all

openconsole()
a$ = programparameter()
printn(a$)
input()
and paste this as program parameter:

Code: Select all

";11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111aaaaa"
User avatar
Blue
Addict
Addict
Posts: 972
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

Post by Blue »

Fred wrote:I just tried, but can't see the limit. Can anyone else confirm ?
Confirmed under Vista SP1.
The test works with your 329-char long argument...
No limit.

BTW:

Code: Select all

Debug #MAX_PATH
returns 260 !
Last edited by Blue on Thu Jun 12, 2008 4:53 pm, edited 1 time in total.
PB Forums : Proof positive that 2 heads (or more...) are better than one :idea:
horst
Enthusiast
Enthusiast
Posts: 197
Joined: Wed May 28, 2003 6:57 am
Location: Munich
Contact:

Post by horst »

Fred wrote:I just tried, but can't see the limit. Can anyone else confirm ?
I am sorry, I just tested again, and found it is a limitation of the Windows shortcut: The Target cannot be longer than #max_path, including the program path and all parameters. This also applies, when you drag&drop a long file name on a shortcut.

PB seems to handle it correctly.
Sorry
Horst.
Fred
Administrator
Administrator
Posts: 18360
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

No problem, interesting to know, will move it to 'Windows' forums.
Post Reply