QUESTION: How do I invoke the Create Shortcut dialog wizard for my application? ANSWER: You will need to add ShellApi and Registry to your uses clause. Next, pass in the directory were you want your shortcut, you may want a variable here to get input from the user. For this example I use Temp:InvokeShortCutDialog('c:Temp');. However, to save it to the DeskTop you would instead do this:
LaunchShortCutDialog('C:Documents and Settings"User Name"Desktop'); or use a string variable: PathShortCut : string, so the function call looks like this:
LaunchShortCutDialog(PathShortCut);. function InvokeShortCutDialog(Directory : string) : boolean; var Reg : TRegistry; CmdLine : string; begin Result := false; Reg := TRegistry.Create; try Reg.Rootkey := HKEY_CLASSES_ROOT; if Reg.OpenKeyReadOnly('.LNKShellNew') then begin CmdLine := Reg.ReadString('Command'); CmdLine := StringReplace(CmdLine, '%1', Directory, []); Result := True; WinExec(PChar(CmdLine), SW_SHOWNORMAL ); end finally Reg.free; end; end; procedure TForm1.Button1Click(Sender: TObject); begin InvokeShortCutDialog('c:Temp'); end; |
Last Modified: 31-AUG-01