获取窗户的把手 [英] Getting the windows's handle

查看:62
本文介绍了获取窗户的把手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个打开的窗口,窗口A和窗口B.如何使用WindowsAPI知道它们是否是Windows资源管理器?

I have two open windows, window A and window B. How can I know if they are windows explorer or not, using windowsAPI?

推荐答案

窗口的类名.如果它是CabinetWClass ExploreWClass,则表明它是资源管理器窗口.

您可以使用GetClassName.

http://msdn.microsoft.com/en-us/library/ms633582 (v = VS.85).aspx [
Look for the window''s classname. If it''s CabinetWClass or ExploreWClass, that''s a good indicator that it''s an Explorer window.

You can use GetClassName.

http://msdn.microsoft.com/en-us/library/ms633582(v=VS.85).aspx[^]


好吧,假设您同时拥有两个窗口的窗口句柄,则可以检索与该窗口句柄关联的进程ID,并且然后枚举正在运行的任务以查找进程ID,如果映像名称为explorer.exe,则鲍勃是您的叔叔.
Well, assuming you have the window handle of both windows, you could retrieve the process ID associated with the window handle, and then enumerate the running tasks looking for the process ID, and if the image name is explorer.exe, bob''s your uncle.


可能是,知道这是Windows资源管理器还是不会给你太多.但是,您没有解释自己的最终目标和方法的主要思想.这也不是100%可靠.

1)任何应用程序都有机会以与Windows资源管理器完全相同的方式呈现您可以从其进程中检测到的所有数据,同时不提供Windows资源管理器的功能.

2)Windows资源管理器没什么特别的,只是另一个应用程序.唯一一件与众不同的事情:如果您杀死名称为"Explorer"的进程,则可以使用开始"菜单删除系统托盘,这非常麻烦!还有许多其他应用程序提供与Windows资源管理器相同的功能,并且还使用Shell API(Shell API是关键,而不是应用程序).我知道人们从不使用Windows资源管理器;我只是其中之一.

因此,由于这些原因,您可能要考虑不依赖Windows资源管理器,而是使用某些替代方法,例如直接使用Shell API.由于您没有分享自己的目标,因此我无法向您提供任何进一步的建议.

—SA
Chances are, knowing is this is a Windows Explorer or not won''t give you much. However, you did not explain you ultimate goal and the main idea of your approach. This is not 100% reliable as well.

1) Any application has a chance to present all data you can detect from its process in the way fully identical to Windows Explorer and at the same time provide no functionality of Windows Explorer.

2) Windows Explorer is nothing special, just yet another application. Just one thing is unique about it: if your kill the process found by name "Explorer", you can remove the system tray with "Start" menu — very disruptive! There are many other applications providing the same functionality as Windows Explorer and beyond and using Shell API as well (Shell API which is a key, not the application). I know people never using Windows Explorer; I''m just one of them.

So, by these reasons you may want to consider not relying on Windows Explorer but using some alternative approach like using Shell API directly. I cannot give you any further advice in this direction as you did not share your goals.

—SA


这篇关于获取窗户的把手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆