Create application shortcuts in C# using ShellLink.cs
Question:
How to programmatically create application shortcuts (.lnk files) in C# using the .NET Framework?
Solution:
While there may not be a direct method, the ShellLink.cs class from vbAccelerator provides a powerful solution that does not rely on WSH.
Implementation:
Using this class you can create shortcuts as follows:
<code class="language-csharp">private static void configStep_addShortcutToStartupGroup() { using (ShellLink shortcut = new ShellLink()) { shortcut.Target = Application.ExecutablePath; shortcut.WorkingDirectory = Path.GetDirectoryName(Application.ExecutablePath); shortcut.Description = "我的快捷方式名称"; shortcut.DisplayMode = ShellLink.LinkDisplayMode.edmNormal; shortcut.Save(STARTUP_SHORTCUT_FILEPATH); } }</code>
Advantages of ShellLink.cs:
The above is the detailed content of How to Programmatically Create Application Shortcuts in C#?. For more information, please follow other related articles on the PHP Chinese website!