unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs;<br><br>type<br> TForm1 = class(TForm)<br> procedure FormCreate(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>uses ComObj, ShlObj, ActiveX;<br><br>//VERSION V1.0<br>//AUTHOR: (Jfyes)<br>//Remark : string to PwideChar<br>//CREATE DATE : 2004-8 / 2004-9<br>function StrToPWideChar(str: String): PWideChar;<br>var<br> pwc: PWideChar;<br>begin<br> GetMem(pwc, Length(str) * Sizeof(PwideChar) + 1);<br> result := StringToWideChar(str, pwc, Length(str) * SizeOf(WideChar) + 1);<br>end;<br><br>//建立快捷方式<br>procedure CreateSellLink(SourceName: string; targetName: string);<br>var<br>tmpObject : IUnknown;<br>tmpSLink : IShellLink;<br>tmpPFile : IPersistFile;<br>StartupFilename : String;<br>begin<br> StartupFilename := SourceName;<br> tmpObject := CreateComObject(CLSID_ShellLink);//创建建立快捷方式的外壳扩展<br> tmpSLink := tmpObject as IShellLink;//取得接口<br> tmpPFile := tmpObject as IPersistFile;//用来储存*.lnk文件的接口<br> tmpSLink.SetPath(pChar(StartupFilename));//设定notepad.exe所在路径<br> tmpSLink.SetWorkingDirectory(pChar(ExtractFilePath(StartupFilename)));//设定工作目录<br> tmpPFile.Save(StrToPWideChar(targetName), true);<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> CreateSellLink(Application.ExeName,<br> 'C:/Documents and Settings/Administrator/Application Data/Microsoft/Internet Explorer/Quick Launch/' + 'MyExe.lnk');<br>end;<br><br>end.