Board index » delphi » Creating a Shortcut to a File : Help

Creating a Shortcut to a File : Help

I'm having trouble implementing the C++ example given in the Win32 API
help titled : Creating a Shortcut to a File. I can't find any mention of
IShellLink in the Delphi help files. How do I work with this interface?

Thanks in advance

Brad Kilmer

 

Re:Creating a Shortcut to a File : Help


Brad,

IShellLink is in the Win32 API help file; you can get to it by
typing IShellLink in the Code Editor, clicking on it, and pressing
F1.

Save yourself some work, though - there's a full example of creating
a shortcut on the Inprise site:

http://www.inprise.com/devsupport/delphi/ti_list/TI1597D.html

HTH

Ken
--
Ken White

Clipper Functions for Delphi
http://members.aol.com/clipfunc

Quote
Brad Kilmer wrote:

> I'm having trouble implementing the C++ example given in the Win32 API
> help titled : Creating a Shortcut to a File. I can't find any mention of
> IShellLink in the Delphi help files. How do I work with this interface?

> Thanks in advance

> Brad Kilmer

Re:Creating a Shortcut to a File : Help


In article <3680B263.6210F...@sierra.net>, Brad Kilmer <BKTa...@sierra.net>
writes:

Quote
>I'm having trouble implementing the C++ example given in the Win32 API
>help titled : Creating a Shortcut to a File. I can't find any mention of
>IShellLink in the Delphi help files. How do I work with this interface?

This was a previous example posted by someone else :-

implementation
{$R *.DFM}

uses  ShlObj, ActiveX, ComObj, Registry;

procedure TForm1.Button1Click(Sender: TObject);
var
  MyObject: IUnknown;   // IUnknown interface
  MySLink: IShellLink; {The IShellLink interface provides an interface to
                        allow an application to create and resolve shell
links}
  MyPFile: IPersistFile; {The IPersistFile interface provides methods for an
                          object to load and save itself in a disk file }
  FileName: String;
  Directory: String;
  WFileName: WideString;
  MyReg: TRegIniFile;
begin
  MyObject := CreateComObject(CLSID_ShellLink);
  MySLink := MyObject as IShellLink;    // See on line help for IShellLink
interface
  MyPFile := MyObject as IPersistFile; // See on line help for IPersistFile
interface
  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');
  // Put the shortcut on your desktop
  Directory := MyReg.ReadString('Shell Folders','Desktop','');

  // put the shortcut on your start menu
  { Directory := MyReg.ReadString('Shell Folders','Start Menu','')+
    CreateDir(Directory); }

  WFileName := Directory + '\NotePad.lnk';
  MyPFile.Save(PWChar(WFileName),False);
  MyReg.Free;
end;

Alan Lloyd
alangll...@aol.com

Re:Creating a Shortcut to a File : Help


Hi, if you ever found out, then please let me know too..i can't
understand the example either.

Gurpal (gs...@ic.ac.uk)

Quote
On Wed, 23 Dec 1998, Brad Kilmer wrote:
>I'm having trouble implementing the C++ example given in the Win32 API
>help titled : Creating a Shortcut to a File. I can't find any mention of
>IShellLink in the Delphi help files. How do I work with this interface?

>Thanks in advance

>Brad Kilmer

------------------------------------------------------------
Windows 95/98/NT:
32 bit extensions and a graphical shell for a
16 bit patch to an
8 bit operating system originally coded for a
4 bit microprocessor, written by a
2 bit company that can't stand
1 bit of competition

Gurpal Singh Bhachu
Information Systems Engineering Yr 2
Department of Computing
Imperial College
180 Queen's Gate
London SW7    
http://www.doc.ic.ac.uk/~gsb97

Other Threads