tags:

views:

300

answers:

3

I've got a code that lists the running application on a win32 box, and then displays theirs icons.

So far so good, I get the hwnd of the app, then call for GetClassLong(hwnd,GCL_HICONSM), and everything's fine.

But the case of a java apps is a pain to deal with, as the process answering to my calls is javaw.exe, and not the shiny-pimpy java application, who's got a so beautiful icon...

I gave a shoot at GetWindowThreadProcessId also, but alas, it's the PID of javaw that's returned...

There's a way to do this though, as the task manager (alt+tab) displays the good icon.

+2  A: 

Mmm, it can be done, because Process Viewer has a Show Applications button which does that (even if the main view shows the Java's icon). Alas this freeware isn't open source, so it won't tell its secret... :-(

Sysinternals' ProcMon doesn't do that, alas.

I will dig a bit more... :-)

[EDIT] Both a MS KB article and a Code Project article recommend using WM_QUERYDRAGICON if GCL_HICON fails...

PhiLho
Well, thanks a lot for your answer, WM_QUERYDRAGICON wasn't the good call, but the codeproject article had it well! I'll update my question so as to give the right algorithm.
Vinzz
A: 

Just get the icon from the window : 1 line of code...

how nice of you to bother to write such a useful answer... Seing your other answers, it seems you are a really helpful guy.
Vinzz
+2  A: 

I answer to my own question, thanks to PhiLho who put me on the right track: an article from Codeproject with the right algorithm to get a window icon (wether it's java or not):

//first, try:

SendMessageTimeout(WM_GETICON)

//if no icon found, try

GetClassLong(GCL_HICONSM)

//if still no icon, try

SendMessageTimeout(WM_WM_QUERYDRAGICON)

//if still no icon, you're doomed, return an error, or a void icon

For some reason a java app answers to the first call, but not to the others, which seems to be handled by javaw.exe.

Thanks again PhiLho.

Vinzz