Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 01-06-2001, 05:53 AM
gLes gLes is offline
Senior Member
 
Join Date: Jan 2001
Posts: 2,273
Default How can I "force" Windows to create a link to a specified file?

I'd like to make an install program for my app and I'd like to know which API function can I use to create a link to my app...
Thx...gLes
Reply With Quote
  #2  
Old 01-06-2001, 08:12 AM
medialight medialight is offline
Junior Member
 
Join Date: Nov 2000
Posts: 4
Default RE: How can I "force" Windows to create a link to a specified file?

Hi,
This should help:

uses
ShlObj, ActiveX, ComObj, Registry;

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 := 'C:\Windows\Notepad.exe';

with MySLink do begin
SetArguments('C:\Autoexec.bat'); // Parameters
SetPath(PChar(FileName));
SetWorkingDirectory(PChar(ExtractFilePath(FileName )));
end;

MyReg := TRegIniFile.Create('Software\MicroSoft\Windows\Cur rentVersion\Explorer');
Directory := MyReg.ReadString('Shell Folders','Desktop','');
WFileName := Directory+'\FooBar.lnk';
MyPFile.Save(PWChar(WFileName),False);
MyReg.Free;

Kind Regards,
Serge M.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 07:55 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2018, vBulletin Solutions, Inc.