无法使用 pinvoke 将 WM_CLOSE 发送到 Windows 资源管理器窗口
我有一个 C# 应用程序,它使用 SendMessage pinvoke 方法向应用程序外部的各个窗口发送“关闭窗口”消息 (WM_CLOSE / 16)。这非常有效,除非相关窗口是 Windows 资源管理器窗口。我没有遇到异常,但窗口没有关闭。
签名如下:
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
internal static extern IntPtr SendMessage(HandleRef hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
我需要向 Windows 资源管理器窗口发送其他消息吗?或者有替代方法来实现这一点?
I have a C# application that uses the SendMessage pinvoke method to send a "close window" message (WM_CLOSE / 16) to various windows outside the application. This works great, except when the window in question is a Windows Explorer window. I do not get an exception, but the window does not close.
Here's the signature:
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
internal static extern IntPtr SendMessage(HandleRef hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
Is there a different message that I need to send to Windows Explorer windows? Or an alternate way to accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
另一种解决方案是使用 PostMessage win API 调用而不是 SendMessage,下面是一个对我来说效果很好的示例(我使用的是 winXP sp3):
PostMessage 和 SendMessage api 调用之间的差异如下所述: http://msdn.microsoft.com/en-us/magazine/cc301431.aspx
an alternative solution would be to use PostMessage win API call instead of SendMessage, below is an example which worked fine for me (I'm using winXP sp3):
differences between PostMessage and SendMessage api call are described here: http://msdn.microsoft.com/en-us/magazine/cc301431.aspx