IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

May Edition
Subscribe now! It's Free!
Enter your email:

   ► MB LobbyPascal and Delphi Coding BoardDelphi News / Other Topic   Print This     

Tip: Create a ShellLink

Tip: Create a ShellLink in Delphi News / Other topic (part of our Pascal and Delphi Coding group).

Quick Search: ShellLink   Tip Create   Tip Create ShellLink  
Most Recent Post
Larry J. Rutledge
Prestwood IT
Citrus Heights, CA USA
Version Info: Works with Delphi 3 and higher.

Category: Shell API

Description:
Create a Windows ShellLink (.lnk) file with Delphi.

Many of the Windows API calls are provided as COM interfaces, including IShellLink. This interface can be used to create a link on the Windows desktop.


uses
ááActiveX, ComObj, ShlObj;

const
ááIID_IPersistFile: TGUID = (D1: $0000010B; D2: $0000; D3: $0000; D4:($C0, $00, $00, $00, $00, $00, $00, $46));

function CreateLink(aPathObj, aPathLink, aDesc: string): Boolean;
var
áásLink: IShellLink;
ááPersFile: IPersistFile;

begin
ááResult := False;
ááif Succeeded(CoCreateInstance(CLSID_ShellLink, nil, CLSCTX_INPROC_SERVER, IID_IShellLinkA, sLink)) then
áábegin
áááásLink.SetPath(PChar(sPathObj));
áááásLink.SetDescription(PChar(aDesc));
ááááif Succeeded(sLink.QueryInterface(IID_IPersistFile, PersFile)) then
áááábegin
ááááááPersFile.Save(StringToOleStr(aPathLink), True);
ááááááResult := True;
ááááend;
ááend;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
ááif not CreateLink('command.com', 'c:\temp\mylink.lnk', 'description...') then
áábegin
áááá// Error Handling
ááend;
end;


-----------
Larry J. Rutledge

Programmer / Analyst
Prestwood Software & Consulting
7525 Auburn Blvd., #8
Citrus Heights, CA 95610


Old UBB Archived Link: [URL=http://www.prestwood.com]www.prestwood.com[/URL]


Serving your IT needs since 1984!


[This message has been edited by Larry Rutledge (edited November 30, 2000).]
Larry J. Rutledge

Analyst

Prestwood Software

www.prestwood.com
 Posted 22 years ago (Thread Starter)
Comment Quote
About Larry J. Rutledge -Collapse +Expand
Visit Profile
Approved member.
Member subscribes to this thread with a verified email.
About Larry J. Rutledge
I worked for Prestwood Software as a Delphi developer from 1997 through 2002. During that time I enjoyed working with Mike Prestwood and the other developers at Prestwood.

Post ID #167, No Replies Be the first!
Thread Started 11/27/2000 10:05:00 AM
View Counter=2025
Location=Citrus Heights, CA USA 
Joined=22 years ago   MB Posts=73   KB Posts=9  

Revive Thread!

Add a comment to revive this old thread and make this archived thread more useful.

Write a Comment...
Full Editor
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1232A1
Enter key:
Icon: A Post    Thread    Idea    Important!    Cool    Sad    No    Yes    Includes a Link...   
Thread #167 Counter
2025
Since 4/2/2008
Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2022 Prestwood IT Solutions.   [Security & Privacy]