Possible Duplicate:
How do you create an application shortcut (.lnk file) in C# or .Net
Hi,
Any clue on how to create shortcut for an .exe in C#?
Thanks
Possible Duplicate:
How do you create an application shortcut (.lnk file) in C# or .Net
Hi,
Any clue on how to create shortcut for an .exe in C#?
Thanks
I found this answer in google, at: http://www.geekpedia.com/tutorial125_Create-shortcuts-with-a-.NET-application.html
Just:
WshShell = new WshShellClass();
// Create the shortcut
IWshRuntimeLibrary.IWshShortcut MyShortcut;
// Choose the path for the shortcut
MyShortcut = IWshRuntimeLibrary.IWshShortcut)WshShell.CreateShortcut(@"C:\MyShortcut.lnk");
// Where the shortcut should point to
MyShortcut.TargetPath = Application.ExecutablePath;
// Description for the shortcut
MyShortcut.Description = "Launch My Application";
// Location for the shortcut's icon
MyShortcut.IconLocation = Application.StartupPath + @"\app.ico";
// Create the shortcut at the given path
MyShortcut.Save();
Just remember to add the reference Windows Script Host Object Model
Here's my Delphi code:
function CreateShellLink(const szFilename: string; const szDescription: string): IShellLinkA;
var
sl: IShellLinkA;
begin
sl := CreateComObject(CLSID_ShellLink) as IShellLinkA;
OleCheck(sl.SetPath(szFilename));
OleCheck(sl.SetDescription(szDescription));
Result := sl;
end;
You'll have to figure out using Win32 api from .NET.