创建应用程序快捷方式的目录 [英] Creating application shortcut in a directory

查看:184
本文介绍了创建应用程序快捷方式的目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建在C#应用程序的快捷方式(.lnk文件),或者使用.NET Framework?

How do you create an application shortcut (.lnk file) in C# or using the .NET framework?

其结果将是一个.lnk文件到指定的应用程序或URL。

The result would be a .lnk file to the specified application or URL.

推荐答案

这不是简单的我会很喜欢,但有一个伟大的阶级调用的 ShellLink.cs 的在 <一href="http://www.vbaccelerator.com/home/net/$c$c/libraries/Shell_Projects/Adding__Deleting_and_Viewing_Recent_Documents/RecentDocuments_$c$c_zip_RecentDocuments%5CShellLink_cs.asp"相对=nofollow> vbAccelerator

It's not as simple as I'd have liked, but there is a great class call ShellLink.cs at vbAccelerator

这code使用互操作,但不依赖于WSH。

This code uses interop, but does not rely on WSH.

使用这个类中,code创建的快捷方式:

Using this class, the code to create the shortcut is:

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);
    }
}

这篇关于创建应用程序快捷方式的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆