Shortcuts made in Delphi

Hello Good Experts!!!
How can i make chortcuts in Delphi?

1. I'm building a little Delphi app that installs programs on network computer like Macro Magic with network share.

2. I copy the files between share e.g c:\ drive and i want to make shortcuts automatically under Winnt\profiles.......

3. how can i do this?

Regards
Trausti
traustiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MadshiCommented:
Yuo can use this function to create a shortCut:

function CreateShortCut(pathObj, pathLink, desc: string) : boolean;
var sl : IShellLink;
begin
  sl:=CreateComObject(CLSID_ShellLink) as IShellLink;
  sl.SetPath(PChar(pathObj));
  sl.SetDescription(PChar(desc));
  result:=(sl as IPersistFile).Save(PWideChar(wideString(pathLink)),true) = 0;
end;

CreateShortCut('c:\winNT\calc.exe', 'c:\calc.lnk', 'Calculator');

This works only for D3-5, not with D2.

Regards, Madshi.
0
men xinCEOCommented:
Trausti:
Use this :

uses
  ShlObj, ActiveX, ComObj, Registry;

....
procedure TForm1.Button1Click(Sender: TObject);
var
  MyObject  : IUnknown;
  MySLink   : IShellLink;
  MyPFile   : IPersistFile;
begin
  MyObject := CreateComObject(CLSID_ShellLink);
  MySLink := MyObject as IShellLink;
  MyPFile := MyObject as IPersistFile;
  with MySLink do begin
    SetPath('myfile.exe');
    SetWorkingDirectory(Pchar('c:\'));
  end;
  MyPFile.Save(PWChar(widestring('c:\winnt\profile\xx.lnk')),False);
end;

menxin
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
men xinCEOCommented:
Oh.sorry,Madshi,we have a same way...
;-)

menxin
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

traustiAuthor Commented:
I get error on IShellLink
0
MadshiCommented:
menxin...  No problem...

trausti, have you added the nessecary units to your uses clause? Look at menxin's answer...

Regards, Madshi.
0
traustiAuthor Commented:
Thanks!!! to all
0
men xinCEOCommented:
trausti :
use shlobj

Ishelllink is in shlobj unit

menxin
0
traustiAuthor Commented:
Thanks!!! to all
0
traustiAuthor Commented:
Sorry!!!

What if i want a folder like "accessories" ?
0
traustiAuthor Commented:
Sorry!!!

What if i want a folder like "accessories" ?
0
men xinCEOCommented:
trausti:

no problem!

you can find the "programs" in

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer].programs!

Then....

menxin
0
traustiAuthor Commented:
Then What, do you have code for button click?
0
traustiAuthor Commented:
Then What, do you have code for button click?
0
men xinCEOCommented:
trausti:
Sure!

use registry;


var MyReg:TRegIniFile;
begin
  MyReg := TRegIniFile.Create(
    'Software\MicroSoft\Windows\CurrentVersion\Explorer');
  showmessage(MyReg.ReadString('Shell Folders','Programs',''));//this is you want
end;

menxin
0
traustiAuthor Commented:
How about if i want to set this link to accessories or make a new folder?
0
traustiAuthor Commented:
Sorry i write again the same code, your answer is great
0
traustiAuthor Commented:
What is that!!!

I mean i want to make shortcut on the computer with new folder
e.g

Start Menu - Programs - MyFolder - The New Shortcut
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.