C#获取exe文件的默认图标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1538558/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C# Get the default icon of an exe file
提问by
Possible Duplicate:
Get File Icon used by Shell
可能的重复:
获取 Shell 使用的文件图标
In my program i am reading a directory of files and displaying them as a ToolStripMenuItem
在我的程序中,我正在读取文件目录并将它们显示为 ToolStripMenuItem
Normally i would use:
通常我会使用:
item.Image = Image.FromFile("icon.ico");
But how would i get the default icon that a given exe uses:
但是我如何获得给定 exe 使用的默认图标:
item.Image = Image.FromEXE("program.exe");
Is there a simple way to do it like that?
有没有一种简单的方法可以做到这一点?
回答by Joel Coehoorn
See my previous question:
Get File Icon used by Shell
看我之前的问题:
Get File Icon used by Shell
In summary, it's really simple. Just call Icon.ExtractAssociatedIcon()
.
总结起来,真的很简单。就打电话Icon.ExtractAssociatedIcon()
。