I've got a code that lists the running application on a win32 box, and then displays theirs icons.
我有一个代码在win32框中列出正在运行的应用程序,然后显示他们的图标。
So far so good, I get the hwnd of the app, then call for GetClassLong(hwnd,GCL_HICONSM), and everything's fine.
到目前为止这么好,我得到应用程序的hwnd,然后调用GetClassLong(hwnd,GCL_HICONSM),一切都很好。
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...
但是java应用程序的情况很难处理,因为回答我的调用的过程是javaw.exe,而不是闪亮的pimpy java应用程序,谁有一个如此漂亮的图标......
I gave a shot at GetWindowThreadProcessId also, but alas, it's the PID of javaw that's returned...
我也试着GetWindowThreadProcessId,但是唉,这是返回的javaw的PID ...
There's a way to do this though, as the task manager (alt+tab) displays the good icon.
有一种方法可以做到这一点,因为任务管理器(alt + tab)显示好图标。
2 个解决方案
#1
3
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... :-(
嗯,它可以完成,因为Process Viewer有一个Show Applications按钮来执行该操作(即使主视图显示了Java的图标)。唉这个免费软件不是开源的,所以它不会告诉它的秘密... :-(
Sysinternals' ProcMon doesn't do that, alas.
唉,Sysinternals的ProcMon不这样做。
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...
[编辑]如果GCL_HICON失败,MS KB文章和Code Project文章都建议使用WM_QUERYDRAGICON ...
#2
5
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):
我回答了我自己的问题,感谢PhiLho让我走上了正确的道路:来自Codeproject的一篇文章,其中有正确的算法来获取一个窗口图标(不管它是不是java):
//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.
出于某种原因,java应用程序会回答第一个调用,但不响应其他人,这似乎是由javaw.exe处理的。
Thanks again PhiLho.
再次感谢PhiLho。
#1
3
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... :-(
嗯,它可以完成,因为Process Viewer有一个Show Applications按钮来执行该操作(即使主视图显示了Java的图标)。唉这个免费软件不是开源的,所以它不会告诉它的秘密... :-(
Sysinternals' ProcMon doesn't do that, alas.
唉,Sysinternals的ProcMon不这样做。
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...
[编辑]如果GCL_HICON失败,MS KB文章和Code Project文章都建议使用WM_QUERYDRAGICON ...
#2
5
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):
我回答了我自己的问题,感谢PhiLho让我走上了正确的道路:来自Codeproject的一篇文章,其中有正确的算法来获取一个窗口图标(不管它是不是java):
//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.
出于某种原因,java应用程序会回答第一个调用,但不响应其他人,这似乎是由javaw.exe处理的。
Thanks again PhiLho.
再次感谢PhiLho。