Thanks Wes. We also found a very good section and example in the
book Mastering Delphi 4.
Steven
> To: Multiple recipients of list
offtopic <[EMAIL PROTECTED]>
> Reply-to: [EMAIL PROTECTED]
> From: "Wes Edwards" <[EMAIL PROTECTED]>
> Subject: RE: [DUG-OFFTOPIC]: Shorcuts
> Date: Thu, 15 Jul 1999 08:29:31 +1200
> Importance: Normal
> from www.borland.com TI's
>
> also look under IShellLink in help for the other properties you can set such
> as Icon etc
>
>
> Technical Information Database
>
> TI1597D.txt - Adding shortcuts to Win95/WinNT4 Desktop/StartMenu
>
> Category :Application Interop
> Platform :All-32Bit
> Product :
>
> Description:
> Title: Adding shortcuts to the Win95/WinNT40 desktop or start menu
>
> This sample project demonstrates an easy way to add shortcuts to
> your Windows 95 or Windows NT 4.0 desktop or start menu.
>
> 1. Launch Delphi.
>
> 2. In a new project, drop a TButton on the form (make sure it's
> called Button1). Then double click on Button1. Now you can go
> ahead and directly replace the code for Unit1 with the code for
> Unit1 below.
>
> The program will set up a shortcut either (see the code) on the
> desktop or on the start menu. The shortcut will be called FooBar
> and it will open up your AUTOEXEC.BAT in NOTEPAD when executed.
>
> It will read the value of the "Desktop" and "Start Menu" strings
> from the registry key named (under HKEY_CURRENT_USER):
>
> Software\MicroSoft\Windows\CurrentVersion\Explorer\Shell Folders
>
> --------------
> The Unit1 unit
> --------------
>
> unit Unit1;
>
> interface
>
> uses
> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
> Dialogs, StdCtrls;
>
> type
> TForm1 = class(TForm)
> Button1: TButton;
> procedure Button1Click(Sender: TObject);
> private
> { Private declarations }
> public
> { Public declarations }
> end;
>
> var
> Form1: TForm1;
>
> implementation
>
> {$R *.DFM}
>
> uses
> ShlObj, ActiveX, ComObj, Registry;
>
> procedure TForm1.Button1Click(Sender: TObject);
> var
> MyObject : IUnknown;
> MySLink : IShellLink;
> MyPFile : IPersistFile;
> FileName : String;
> Directory : String;
> WFileName : WideString;
> MyReg : TRegIniFile;
> begin
> MyObject := CreateComObject(CLSID_ShellLink);
> MySLink := MyObject as IShellLink;
> MyPFile := MyObject as IPersistFile;
> FileName := 'NOTEPAD.EXE';
> with MySLink do begin
> SetArguments('C:\AUTOEXEC.BAT');
> SetPath(PChar(FileName));
> SetWorkingDirectory(PChar(ExtractFilePath(FileName)));
> end;
> MyReg := TRegIniFile.Create(
> 'Software\MicroSoft\Windows\CurrentVersion\Explorer');
>
> // Use the next line of code to put the shortcut on your desktop
> Directory := MyReg.ReadString('Shell Folders','Desktop','');
>
> // Use the next three lines to put the shortcut on your start menu
> // Directory := MyReg.ReadString('Shell Folders','Start Menu','')+
> // '\Whoa!';
> // CreateDir(Directory);
>
> WFileName := Directory+'\FooBar.lnk';
> MyPFile.Save(PWChar(WFileName),False);
> MyReg.Free;
> end;
>
> end.
>
>
> Reference:
>
>
> 4/1/99 4:39:45 PM
>
>
> Trademarks & Copyright ) 1999 INPRISE Corporation.
>
> Wes Edwards
> NZCE BE M.IPENZ Reg.Eng
> Quality Assurance Manager
> CommSoft Group Limited
> ph:+64 9 358 5900 fax:+64 9 358 5901
> [EMAIL PROTECTED]
>
> SmartCharge ... on every switch
>
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]]On Behalf Of Steven Wild
> > Sent: Thursday, 15 July 1999 7:29
> > To: Multiple recipients of list offtopic
> > Subject: [DUG-OFFTOPIC]: Shorcuts
> >
> >
> > Hi
> >
> > Anyone know how to create shortcuts from within code.
> >
> > Steven
> > Director
> >
> > Wild Software Ltd
> > P O Box 33-216
> > Christchurch
> > NEW ZEALAND
> >
> > --------------------------------------------------------------
> > -------------
> > New Zealand Delphi Users group - Offtopic List -
> > [EMAIL PROTECTED]
> > Website: http://www.delphi.org.nz
> >
>
> ---------------------------------------------------------------------------
> New Zealand Delphi Users group - Offtopic List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
>
>
Director
Wild Software Ltd
P O Box 33-216
Christchurch
NEW ZEALAND
---------------------------------------------------------------------------
New Zealand Delphi Users group - Offtopic List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz