Do Windows keyboard shortcuts support very long argument lengths?

I am trying to create a shortcut (on the desktop) containing a long line of argument (> MAX_PATH).

The MSDN documentation clearly states that for a Unicode string, the string may be longer than MAX_PATH.

The resulting label is cut exactly after the MAX_PATH characters (i.e. Path+ the Arguments).

Is there something wrong with my implementation or is this a limitation of Windows?

procedure CreateShortcut(APath: WideString;
  AWorkingDirectory: WideString; AArguments: WideString; ADescription: WideString;
  ALinkFileName: WideString);
var
   IObject : IUnknown;
   ISLink  : IShellLinkW;
   IPFile  : IPersistFile;
begin
   IObject := CreateComObject(CLSID_ShellLink);
   ISLink := IObject as IShellLinkW;
   ISLink.SetPath(            PWideChar(APath));
   ISLink.SetWorkingDirectory(PWideChar(AWorkingDirectory));
   ISLink.SetArguments(       PWideChar(AArguments));
   ISLink.SetDescription(     PWideChar(ADescription));
   IPFile := IObject as IPersistFile;
   IPFile.Save(PWideChar(ALinkFileName), False);
end;

PS: OS - Windows XP (and higher).

+5
source share
2 answers

, Explorer. 260 . , Target , . , GetPath .

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;

test.bat :

echo %1> test.out

test.out _the_end!

+11

, - .

, , , :

1) Windows 7 Enterprise ~ SP1 , VBS - ( ) . 1023 , . , Delphi.

2) Windows XP Professional ~ SP3, VBS 260 ( lnk ), , , .

+4

All Articles