关闭窗口(通过窗口句柄)而不关闭拥有该窗口的进程
我正在尝试从我无权访问其代码的进程中关闭各个窗口。该程序在按下按钮时会生成看起来像 Internet Explorer 窗口的内容,但它们不会创建 iexplorer.exe 进程(它们显然都位于应用程序进程内)。我已经设法通过一些 API 调用获取每个“假”IE 窗口的进程句柄和窗口句柄,但我不知道如何仅关闭进程中的给定窗口。
我试过
SendMessage(WindowHandles[i], 0x0010, 0, 0);
哪个是WM_CLOSE消息,但它关闭了进程中的所有窗口并结束了进程。有没有一种方法可以以编程方式执行类似于按窗口右上角的 X 时发生的操作?该窗口不执行任何计算或影响任何其他内存空间,因此我可以随心所欲地结束它,但是我已经尝试了我知道如何做的所有事情(DestroyWindow; 返回错误 5 权限被拒绝,WM_CLOSE; 有效,但关闭进程,WM_QUIT;这会给出错误 2 文件未找到并且不执行任何操作)。
有什么想法吗?
I'm trying to close individual windows from a processes whose code I do not have access to. The program spawns what look like internet explorer windows upon a button push, but they do not create an iexplorer.exe process (they all apparently live inside the application process). I've managed to get the process handle and the window handles for each "fake" IE window via some API calls, but I can't figure out how to close just a given window in a process.
I've tried
SendMessage(WindowHandles[i], 0x0010, 0, 0);
which is the WM_CLOSE message, but it closes all the windows in the process and ends the process. Is there a way to programmatically do something similar to what happens when I press the X at the top right corner of the window? The window isn't performing any computation or effecting any other memory spaces so I can end it however I want, but everything I've tried everything I know how to do (DestroyWindow; which returned error 5 permission denied, WM_CLOSE; which works but closes the process, WM_QUIT; which gives error 2 file not found and does nothing).
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以发送 SW_HIDE 在技术上应该可以工作,尽管它不会关闭它们,您可以在以下位置找到更多信息
http://msdn.microsoft.com/en-我们/library/ms633548(v=vs.85).aspx
You could send a SW_HIDE should technically work, although it wont close them, you can find more info at
http://msdn.microsoft.com/en-us/library/ms633548(v=vs.85).aspx