3

我在尝试WM_CLOSE窗口资源管理器进程时遇到问题,因为发送该消息将尝试关闭 Windows Shell 资源管理器进程并提示用户关闭窗口。这不是预期的行为,我想知道如何解决它?

如何优雅地关闭单个资源管理器窗口,而不同时关闭整个 PC?目标是具有与用户自己单击 X 按钮相同的行为。

编辑:我发现我能够获取资源管理器进程的所有子窗口,但从那时起,我不确定如何识别哪些窗口是实际的、用户可见/可交互的资源管理器窗口。

11/21/2012 16:27:49 [12]  DEBUG - Closing process with PID: 2680
11/21/2012 16:27:49 [12]  DEBUG - Window has 11 descendant windows
11/21/2012 16:27:49 [12]  DEBUG - Found child window:  hWnd: 590746 Window State: Normal
11/21/2012 16:27:49 [12]  DEBUG - Found child window: 4:27 PM hWnd: 656010 Window State: Normal
11/21/2012 16:27:49 [12]  DEBUG - Found child window:  hWnd: 2294392 Window State: Normal
11/21/2012 16:27:49 [12]  DEBUG - Found child window:  hWnd: 1245586 Window State: Normal
11/21/2012 16:27:49 [12]  DEBUG - Found child window: User Promoted Notification Area hWnd: 2949496 Window State: Normal
11/21/2012 16:27:49 [12]  DEBUG - Found child window: System Promoted Notification Area hWnd: 1245548 Window State: Normal
11/21/2012 16:27:49 [12]  DEBUG - Found child window:  hWnd: 852646 Window State: Normal
11/21/2012 16:27:49 [12]  DEBUG - Found child window:  hWnd: 918356 Window State: Normal
11/21/2012 16:27:49 [12]  DEBUG - Found child window: Running applications hWnd: 1769950 Window State: Normal
11/21/2012 16:27:49 [12]  DEBUG - Found child window: Running applications hWnd: 1179980 Window State: Normal
11/21/2012 16:27:49 [12]  DEBUG - Found child window: TF_FloatingLangBar_WndTitle hWnd: 458926 Window State: Normal
4

1 回答 1

1

你怎么弄到窗户的?您可以通过文本获取带有 winapi 调用的句柄,因此桌面资源管理器可能没有标题。http://msdn.microsoft.com/en-us/library/windows/desktop/ms633499(v=vs.85).aspx查看lpWindowName参数。

另外,我只是在这里猜测,您可能会查看桌面资源管理器和其他资源管理器实例之间的关系,以及它们与 GetDesktopWindow() 返回的手柄的关系http://msdn.microsoft.com/en -us/library/windows/desktop/ms633504(v=vs.85).aspx

于 2012-11-21T20:54:20.550 回答