如何用代码修改快捷方式的图标?

kakery1986 2014-05-08 10:32:31
比如在 c:\ProgramData\Microsoft\Windows\Start Menu\Programs\xxxxx\xxxx.lnk
xxxxx\xxxx.lnk 是应用程序的快捷方式
求教如何修改其图标?
System.IO.FileInfo 或 File 似乎没有相关的属性
(自己做的应用程序,基于wpf,写了更新程序以替换文件的方式升级,但换不了快捷方式图标,所以想通过代码来操作)
...全文
97 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
jimil 2014-05-08
  • 打赏
  • 举报
回复
[DllImport("shell32.DLL", EntryPoint = "ExtractAssociatedIcon")] private static extern int ExtractAssociatedIconA(int hInst, string lpIconPath, ref int lpiIcon); //声明函数 System.IntPtr thisHandle; public System.Drawing.Icon SetIcon(string s)//S是要获取文件路径,返回ico格式文件 { int RefInt = 0; thisHandle = new IntPtr(ExtractAssociatedIconA(0, s, ref RefInt)); return System.Drawing.Icon.FromHandle(thisHandle); }

111,092

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧