?
Solved

Windows shortcut/lnk files...

Posted on 1998-09-22
3
Medium Priority
?
807 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 300 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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 Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

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