Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting the icon associated with a running application

Tags:

c#

winapi

Having the window handle for an open application, I'm able to use the GetWindowText function to retrieve the text from the title bar of the app. I would like to take this a step farther and retrieve the icon associated with the same app.

How might I go about doing this? I looked through what I thought would be the relevant Win32 API sections, but nothing jumped out at me.

Any pointers would be appreciated.

Thanks in advance!

like image 862
Brian K. Carroll Avatar asked Nov 20 '08 01:11

Brian K. Carroll


People also ask

What is an icon in an application?

In today's modern context, an icon is an image on the computer screen that represents an application, a capability, or some other concept or specific entity with meaning for the user.

What are application icons examples?

An icon on your computer screen represents an object or a program on your hard drive. For example, the folders you see on your desktop or in open windows are icons. The files that you see in those folders are also icons. The trash can on the Macintosh and the recycle bin on Windows are both icons as well.


1 Answers

Icon ico = Icon.ExtractAssociatedIcon(theProcess.MainModule.FileName);

From TheSoftwareJedi

Initially this appears to be an exact duplicate of How can I get the icon from the executable file only having an instance of it's Process in C# but that one seems to focus largely on how to get it from within it's own self, whereas you may be asking how to get the icon using a program separate from the running process.

-Adam

like image 121
Adam Davis Avatar answered Nov 07 '22 20:11

Adam Davis