如何在桌面上添加图标到应用程序的快捷方式 [英] how to add icon to application's shortcut in desktop

查看:196
本文介绍了如何在桌面上添加图标到应用程序的快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望当用户运行我的c#应用程序时,应用程序将创建一个桌面快捷方式来运行应用程序。我使用此代码:

I want when user runs my c# application , the application will create a desktop shortcut to run application. I use this code :

private void appShortcutToDesktop(string linkName)
{
    string deskDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

    using (StreamWriter writer = new StreamWriter(deskDir + "\\" + linkName + ".url"))
    {
        string app = System.Reflection.Assembly.GetExecutingAssembly().Location;
        writer.WriteLine("[InternetShortcut]");
        writer.WriteLine("URL=file:///" + app);
        writer.WriteLine("IconIndex=0");
        string icon = app.Replace('\\', '/');
        writer.WriteLine("IconFile=" + icon);
        writer.Flush();
    }
}

private void button1_Click(object sender, EventArgs e)
{
    appShortcutToDesktop("MyName");
}

此代码创建快捷方式,但我想放 myicon .ico 用于快捷方式图标。
我该怎么办?

This code creates shortcut but I want to put myicon.ico for shortcuts icon . how can I do this ?

推荐答案

您可以使用以下步骤:



  1. 解决方案资源管理器 中右键单击您的项目,然后选择 属性

  2. 应用程序标签

  3. 图标和清单

  4. 选择 图标

  1. Right click on your project in the Solution Explorer and select Properties.
  2. Application tab
  3. Icon and manifest
  4. Select icon


这篇关于如何在桌面上添加图标到应用程序的快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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