gpt4 book ai didi

c# - 怎么给桌面应用程序快捷方式添加图标

转载 作者:行者123 更新时间:2023-11-30 20:22:29 29 4
gpt4 key购买 nike

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

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 用于快捷方式图标。我该怎么做?

最佳答案

您可以使用以下步骤:

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

关于c# - 怎么给桌面应用程序快捷方式添加图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31472297/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com