Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


How to create .LNK files?

Posted on 1999-07-21
Medium Priority
Last Modified: 2010-04-04
Hi there!
How to easily create a link file (.LNK)?
Suppose I want to put a link in the Windows Startup folder to my program, how to do that?
Thanks in advance!
Question by:mauromol
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 27

Expert Comment

ID: 1390137
LVL 10

Accepted Solution

Lischke earned 400 total points
ID: 1390138
hi mauromol,

use this function to create your link file:

function MakeStartMenuLink(Name, Folder, ExeName, WorkingDir: String): Integer;

// Name       : name of the link without the ".lnk" extension
// Folder     : folder in the startmenu where the link should be placed in
// ExeName    : filename and path of the executable
// WorkingDir : working directory of the program

var AReg      : TRegIniFile;
    AObject   : IUnknown;
    ASLink    : IShellLink;
    APFile    : IPersistFile;
    Directory : String;
    WFileName : WideString;
    R         : HRESULT;

  Result := erOK;
  AObject := CreateComObject(CLSID_ShellLink);
  ASLink := AObject as IShellLink;
  APFile := AObject as IPersistFile;
  with ASLink do begin

  AReg := TRegIniFile.Create('Software\MicroSoft\Windows\CurrentVersion\Explorer');
    Directory := AReg.ReadString('Shell Folders', 'Programs', '')+'\'+Folder;
    if not DirectoryExists(Directory) then Result := erDirectory;
    if (Length(Name) > 0) and (Name[Length(Name)] = '\') then Delete(Name, Length(Name), 1);
    WFileName := Directory+'\'+Name+'.lnk';
    R := APFile.Save(PWChar(WFileName), False);
    if R = E_FAIL then Result := Result or erFile;

Ciao, Mike

LVL 15

Expert Comment

ID: 1390139
I was here!
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 1390140
Thank you very much to both meikl and Mike (how did you know I'm Italian? :-)
LVL 10

Expert Comment

ID: 1390141
mauromol, I didn't know that you are an Italian, where have you got the impression from I'd knew it?

Ciao, Mike

PS: Aah, perhaps you thought this because of my "Ciao"? Well, this is my usual greeting phrase I'm using now since about 5 years...

Author Comment

ID: 1390142
Yes, it was "Ciao" :-)
Bye! Mauro.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

662 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question