Solved

Windows shortcut/lnk files...

Posted on 1998-09-22
3
804 Views
Last Modified: 2008-03-03
Is there a way, either through Delphi (D3) or the Win API, that I can either create a desktop shortcut/lnk file or just modify the path program path in an existing shortcut/lnk? I would prefer to create the entire file. TANKS in advance.
0
Comment
Question by:TonyMalo
[X]
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
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
JimBob091197 earned 100 total points
ID: 1340529
Hi

The following code can be used to create a shortcut to Notepad on your desktop (assuming your desktop path is C:\Windows\Desktop).

var
  SL: IShellLink;
  PF: IPersistFile;
  wPath: array[0..MAX_PATH] of WideChar;
begin
  SL := CreateComObject(CLSID_ShellLink) as IShellLink;
  SL.SetPath(PChar('C:\Windows\Notepad.exe'));
  PF := (SL as IPersistFile);
  MultiByteToWideChar(CP_ACP, 0, PChar('C:\Windows\Desktop\Notepad.lnk'), -1, wPath, MAX_PATH);
  PF.Save(wPath, True);
end;

You will need to add ComObj, ShlObj and ActiveX to your uses clause.

Regards,
JB
0
 

Expert Comment

by:bome
ID: 1340530
just a comment:
in serious programs, DON'T use fixed paths for the windows install dir. There are enough programs (especially professional programs) that don't handle that right... for example I have autostart entries in 3 languages, "Program Files" directories in 3 langages and 2 partitions, etc...
I certainly don't mean you, JimBob, because that serves as an example.
Is it..well... just a comment !

bome

0
 
LVL 5

Expert Comment

by:JimBob091197
ID: 1340531
> Is it..well... just a comment !

And a good comment too!  As you say, there are too many programs that don't handle directories properly.

My home PC has 1 profile for me, and another for my wife, so that PC doesn't have a C:\Windows\Desktop folder.
My desktop is actually C:\Windows\Profiles\David\Desktop.

Cheers,
Dave
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

762 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