Icon of currently running programs
Hello,
I am creating a program and would like so somehow be able to get the Icons of all the currently running programs and then place them into an image control that i created in my program.
I can get the name and everything else of all the currently running programs but i am not able to find a way of how to get that icons.
Thanks alot for anyhelp
Re: Icon of currently running programs
Have you tried to use SendMessage API with the WM_GETICON message?
Edited: Another option, probably more in line with what you are asking for.
1. Get the module name that started the process (GetModuleFileNameEx)
2. Then use ExtractAssociatedIcon.
WM_GETICON obviously won't work if there is no window to get an icon from.
Re: Icon of currently running programs
Thanks alot for the help, would it be possible to find the file or the file name of the running program?
Re: Icon of currently running programs
You said you have the name for all running programs? If so, then ExtractAssociatedIcon is what you want. If you have the process IDs of all current processes, then use GetModuleFileNameEx to get that name.
Re: Icon of currently running programs
Hello, sorry again but im getting quite confused with all these numbers i get, i am able to get the handle to the window, like hwnd, and then i am able to get that process ID using GetWindowThreadProcessId, but GetModuleFileNameEx calls for a handle to the process and a handle to the module, maybe im just missing something but i am getting confused with all the different numbers, maybe i just dont understand it with all the different handles, thanks alot for the help!
Re: Icon of currently running programs
Hello, ok sorry about the last post, i finally figured it out, i got it im not sure how but i did, now the only thing is that GetModuleFileNameEx returns a number, the length of the string of the file name, so how could i get the actually file name into a string, so the string would equaly C:/Program Files/ whatever and so on
Re: Icon of currently running programs
Can you share what you are using to get "the names of all the currently running programs"? Your quote from post#1. I assume the icon is the one you want that is associated with the main app (i.e., the one you would see in Explorer for an exe for example). FYI: Not all processes have windows.