最近在写一个软件的安装程序,快捷方式如下。亲测有效~~
procedure TOne.createLnk(Sender: TObject);
var
AnObj: IUnknown;
ShLink: IShellLink;
PFile: IPersistFile;
FileName: string;
WFileName: WideString;
Reg: TRegIniFile;
begin
AnObj := CreateComObject (CLSID_ShellLink);
ShLink := AnObj as IShellLink;
PFile := AnObj as IPersistFile;
// 得到执行程序的完整路径及文件名
filename:='*****';
ShLink.SetPath (PChar (FileName));
ShLink.SetWorkingDirectory (PChar (
ExtractFilePath (FileName)));
//创建桌面快捷方式
Reg := TRegIniFile.Create(
'Software\MicroSoft\Windows\CurrentVersion\Explorer');
WFileName := Reg.ReadString ('Shell Folders', 'Desktop', '') +
'\' + extractFilename(filename)+ '.lnk';
Reg.Free;
PFile.Save (PWChar (WFileName), False);
//创建“开始”菜单
Reg := TRegIniFile.Create(
'Software\MicroSoft\Windows\CurrentVersion\Explorer');
WFileName := Reg.ReadString ('Shell Folders', 'Start Menu', '') +
'\' + extractFilename(filename) + '.lnk';
Reg.Free;
PFile.Save (PWChar (WFileName), False);
end;
*************************************
uses ComObj, ActiveX, ShlObj, Registry;