我可以从进程中获取可执行文件位置,如何从文件中获取图标?
也许使用windows api LoadIcon().我想知道是否有.NET方式......
The*_*edi 40
Icon ico = Icon.ExtractAssociatedIcon(theProcess.MainModule.FileName);
Run Code Online (Sandbox Code Playgroud)
Rob*_*obS 13
这是来自控制台应用程序实现的示例.
using System;
using System.Drawing; //For Icon
using System.Reflection; //For Assembly
namespace ConsoleApplication
{
class Program
{
static void Main(string[] args)
{
try
{
//Gets the icon associated with the currently executing assembly
//(or pass a different file path and name for a different executable)
Icon appIcon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
}
catch(ArgumentException ae)
{
//handle
}
}
}
}
Run Code Online (Sandbox Code Playgroud)