小编典典

在目录中创建应用程序快捷方式

c#

如何在C#中或使用.NET框架创建应用程序快捷方式(.lnk文件)?

结果将是指向指定应用程序或URL的.lnk文件。


阅读 323

收藏
2020-05-19

共1个答案

小编典典

这不是那么简单,我会很喜欢,但有一个很大的一流的呼叫ShellLink.cs
vbAccelerator

此代码使用互操作,但不依赖WSH。

使用此类,创建快捷方式的代码为:

private static void configStep_addShortcutToStartupGroup()
{
    using (ShellLink shortcut = new ShellLink())
    {
        shortcut.Target = Application.ExecutablePath;
        shortcut.WorkingDirectory = Path.GetDirectoryName(Application.ExecutablePath);
        shortcut.Description = "My Shorcut Name Here";
        shortcut.DisplayMode = ShellLink.LinkDisplayMode.edmNormal;
        shortcut.Save(STARTUP_SHORTCUT_FILEPATH);
    }
}
2020-05-19