问题
How can I get a Window's icon from its Pointer or Process/Process Name? The Icon shown in the corner of the Window or on the Task-bar or in the ALT-Tab menu.
回答1:
read about Icon.ExtractAssociatedIcon
:
Returns an icon representation of an image that is contained in the specified file.
private void ExtractAssociatedIconEx()
{
Icon ico =
Icon.ExtractAssociatedIcon(@"C:\WINDOWS\system32\notepad.exe");
this.Icon = ico;
}
http://msdn.microsoft.com/en-us/library/system.drawing.icon.extractassociatedicon.aspx
This won't work on every process but it's a good start..
also take a look at those answers - How can I get the icon from the executable file only having an instance of it's Process in C#
回答2:
Would Icon.ExtractAssociatedIcon work for you?
来源:https://stackoverflow.com/questions/9968648/how-to-get-a-windows-icon-in-c-sharp