现在有两个应用程序app1和app2
app1得到app2的主窗体句柄后,用sendmessage或postmessage发送向app2发送
WM_QueryEndSession消息。app2可以响应WM_QueryEndSession消息。我的意图是通过发送WM_QueryEndSession让app2结束。但两个应用程序都失去了控制权。都不能继续运行了。
而且app2也并没有结束。两个程序都只能通过任务管理器关闭了。不知是什么原因。请各位帮忙
解决以下!谢谢!
app1得到app2的主窗体句柄后,用sendmessage或postmessage发送向app2发送
WM_QueryEndSession消息。app2可以响应WM_QueryEndSession消息。我的意图是通过发送WM_QueryEndSession让app2结束。但两个应用程序都失去了控制权。都不能继续运行了。
而且app2也并没有结束。两个程序都只能通过任务管理器关闭了。不知是什么原因。请各位帮忙
解决以下!谢谢!
解决方案 »
- 超难的难题,请大家讨论,来者有分!
- 在vb里调用EXCEL,能不能打开两个工作区(sheet)???在线等待!!
- 【悬赏】20分送给第一个完美解决的朋友:关于字符串的处理
- 奇怪,使用MSCOM控件控制信号灯,相同的程序结果却不同?
- VB 如何调用 ACCESS 的“同步复制—>创建副本”功能?
- 该代码为何在WIN9X中无效,而在WIN2000/XP中却有效
- Activebar怎样实现象普通TEXT中Tab键可能由一个文本框到别一个文本框
- 关于form的有关问题请大家告诉我一下谢谢
- VB创建文件夹,要求是一个自定义的文件夹!
- VB編程中的打印控件﹗高分
- SQL SERVER ADO数据库编程登陆界面的一个问题,急!!!!!
- 做过曲线图的同志们,能给一个例子子吗?
发个WM_CLOSE信息试试
HWND hwnd, // handle to window
WM_QUERYENDSESSION, // the message to send
WPARAM wParam, // not used
LPARAM lParam // logoff option
);
Parameters
wParam
This parameter is reserved for future use.
lParam
Specifies whether the user is logging off or shutting down the system. If this parameter includes the ENDSESSION_LOGOFF value, the user if logging off. (Note that this parameter is a bit mask. To test for this value, use a bit-wise operation; do not test for equality.)
Windows 2000/XP: If this parameter is zero, the system is shutting down. Return Values
If an application can terminate conveniently, it should return TRUE; otherwise, it should return FALSE. Res
By default, the DefWindowProc function returns TRUE for this message. Windows NT/2000/XP: When an application returns TRUE for this message, it receives the WM_ENDSESSION message and it is terminated, regardless of how the other applications respond to the WM_QUERYENDSESSION message. Windows 95/98/Me: After all applications return TRUE for this message, they receive the WM_ENDSESSION and they are terminated. Requirements
Windows NT/2000/XP: Included in Windows NT 3.1 and later.
Windows 95/98/Me: Included in Windows 95 and later.
Header: Declared in Winuser.h; include Windows.h.See Also
System Shutdown Overview, System Shutdown Messages, DefWindowProc, ExitWindows, WM_ENDSESSION
情况还是那样。两个程序都失去了控制权。
是不是我关闭进程的方法有问题呀!
应该如何让一个进程通知另一个进程自己结束呢?
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Const WM_CLOSE = &H10Private Sub Command1_Click()
Dim mhwnd As Long
mhwnd = FindWindow("ThunderRT6FormDC", "form1")
SendMessage mhwnd, WM_CLOSE, 0, 0
End Sub