客先でショートカットの内容を判断して書き換える必要に迫られまして・・・
同じようなアプリを置き換えるときに探してショートカットも置き換えてねと…
よく考えたらExcelからOpenOfficeに変えてもExcelにドキュメントを引数で渡すようなショートカットでなく、素直にドキュメントへのショートカットを作っておけば対応できるアプリが普通に対応してくれるんですけどね。
と愚痴っても仕方がないので、まずは一般的なショートカットの作成方法
uses に ActiveX, ComObj, ShlObj を追加する必要があるので忘れず追加!
///ショートカットの作成 /// ショートカットのファイル名 /// コマンドライン文字列(ファイル名) /// コマンドライン文字列(引数) /// 作業場所文字列(引数) /// 説明文字列 function CreateShortCut(const ShortcutPath: String; const ExecFilePath: String; const Params: String; const WorkingDir: String = ''; const Description: String = ''): Boolean; var ShellLink: IShellLink; PersistFile: IPersistFile; {$IFDEF Unicode} FileName: String; {$ELSE} FileName: WideString; {$ENDIF} begin // Create shell link object // Get IShellLink/IPersistent inferface ShellLink := CreateComObject(CLSID_ShellLink) as IShellLink; PersistFile := ShellLink as IPersistFile; // Set path to shell link ShellLink.SetPath(PChar(ExecFilePath)); // Set arguments to shell link ShellLink.SetArguments(PChar(Params)); // Set description string ShellLink.SetDescription(PChar(Description)); // Set working directory ShellLink.SetWorkingDirectory(PChar(WorkingDir)); // Set location (path and index) of the icon ShellLink.SetIconLocation(PChar(ExecFilePath), 0); // Save to file FileName := ShortcutPath; {$IFDEF Unicode} Result := Succeeded(PersistFile.Save(PChar(FileName), True)); {$ELSE} Result := Succeeded(PersistFile.Save(PWChar(FileName), True)); {$ENDIF} end;