Свою версию предлагает Nomadic:
function CreateShortcut(const CmdLine, Args, WorkDir, LinkFile: string): IPersistFile; var MyObject : IUnknown; MySLink : IShellLink; MyPFile : IPersistFile; WideFile : WideString; begin MyObject := CreateComObject(CLSID_ShellLink); MySLink := MyObject as IShellLink; MyPFile := MyObject as IPersistFile; with MySLink do begin SetPath(PChar(CmdLine)); SetArguments(PChar(Args)); SetWorkingDirectory(PChar(WorkDir)); end; WideFile := LinkFile; MyPFile.Save(PWChar(WideFile), False); Result := MyPFile; end; procedure CreateShortcuts; var Directory, ExecDir: String; MyReg: TRegIniFile; begin MyReg := TRegIniFile.Create( 'Software\MicroSoft\Windows\CurrentVersion\Explorer'); ExecDir := ExtractFilePath(ParamStr(0)); Directory := MyReg.ReadString('Shell Folders', 'Programs', '') + '\' + ProgramMenu; CreateDir(Directory); MyReg.Free; CreateShortcut(ExecDir + 'Autorun.exe', '', ExecDir, Directory + '\Demonstration.lnk'); CreateShortcut(ExecDir + 'Readme.txt', '', ExecDir, Directory + '\Installation notes.lnk'); CreateShortcut(ExecDir + 'WinSys\ivi_nt95.exe', '', ExecDir, Directory + '\Install Intel Video Interactive.lnk'); end; |
Разберешься?
Гм. Вообще правильнее в процедуре CreateShortcuts пользовать Win32API::GetSpecialFolderLocation с нужным параметром (CSIDL_PROGRAMS в случае папки "Программы", или CSIDL_DESKTOP в случае "Рабочего стола"). [001599]