Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3949332
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:28:52+00:00 2026-05-20T01:28:52+00:00

I am trying to create a shortcut (on the Desktop) that contains a long

  • 0

I am trying to create a shortcut (on the Desktop) that contains a long argument string (> MAX_PATH).

The MSDN documentation clearly states that for Unicode string the string can be longer than MAX_PATH.

The resulting shortcut is cut exactly after MAX_PATH characters (that is the Path + the Arguments).

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

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 is Windows XP (and above).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T01:28:53+00:00Added an answer on May 20, 2026 at 1:28 am

    It turns out that this issue is in fact solely a limitation in the Explorer shell dialog. The generated shortcut file does not have a 260 character limitation. It’s simply that the dialog refuse to display a Target with more characters than that. Presumably 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 test.bat looks like this:

    echo %1> test.out
    

    The resulting test.out goes right the way to _the_end!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a shortcut on the home screen that, when pressed, will
I'm trying to create programmability a home shortcut for any installed application. Considering that
I am trying to create a desktop shortcut to one of my Activity in
I'm trying to create shortcut keys for some commonly used sudo shell commands (for
I'm trying to create a shortcut to an existing command in vim. Specifically, I'm
I'm trying to create a windows form app that will be able to handle
I have an application that creates a shortcut on my desktop and allows you
I'm trying to create a keyboard shortcut to save my file in vim, so
Im trying to create an application launcher using vb.net. I'm trying to launch desktop
I am trying to create multiple shortcuts to my application that pass different arguments

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.