[ACCEPTED]-Do Windows shortcuts support very long argument lengths?-maxlength
It turns out that this issue is in fact 8 solely a limitation in the Explorer shell 7 dialog. The generated shortcut file does 6 not have a 260 character limitation. It's 5 simply that the dialog refuse to display 4 a Target with more characters than that. Presumably 3 it calls GetPath
with a fixed length buffer.
procedure TForm11.Button1Click(Sender: TObject);
var
sl: IShellLinkW;
pf: IPersistFile;
begin
CoCreateInstance(CLSID_ShellLink, nil,
CLSCTX_INPROC_SERVER, IID_IShellLinkW, sl);
sl.SetPath('c:\desktop\test.bat');
sl.SetWorkingDirectory('c:\desktop\');
sl.SetArguments(PChar(StringOfChar('x', 300)+'_the_end'));
pf := sl as IPersistFile;
pf.Save('c:\desktop\test.lnk', False);
end;
My 2 test.bat
looks like this:
echo %1> test.out
The resulting test.out
goes right 1 the way to _the_end!
Thanks all who contributed to this thread 13 - it helped me immensely.
However, if I may, I 12 would like to add the below information 11 I discovered in crafting my solution:
On 10 Windows 7 Enterprise ~SP1, it would seem 9 that using VBS to create the shortcut there is still a limit on maximum 8 characters in (at least) the arguments field. I 7 tested up to 1023 chars before it got trunicated. I 6 presume the same limit would apply to the 5 Delphi method likewise.
On Windows XP Professional 4 ~SP3, while the VBS method will create a 3 shortcut longer than 260 characters (lnk 2 file contains the data), it seems to trunicate 1 it at about this number when executing it.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.