如何在程序中结束另外一个程序

ynhelian 2000-09-04 01:30:00
加精
要在程序中结束另外一个程序,一是不会用 exitprocess 函数,另外查了许多资料,都建议不使用exitprocess . 而是向要关闭窗口发送WM-CLOSE 消息,这个消息应该用什么函数来发哪?请讲具体点,谢谢!
...全文
190 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
shines77 2000-09-05
  • 打赏
  • 举报
回复
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Const WM_CLOSE = &H10

PostMessage hwnd, WM_CLOSE, 0&, 0&

即可,

hwnd为关闭窗口的句柄。
prefix 2000-09-04
  • 打赏
  • 举报
回复
wm_close只能使窗口最小化。
songs 2000-09-04
  • 打赏
  • 举报
回复
去看看这个地址:
http://expert.csdn.net/Topic/15259.shtm
--茶-- 2000-09-04
  • 打赏
  • 举报
回复
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Dim hanDle As Long
Const WM_CLOSE = &H10
hanDle = FindWindow(0&, "About GVBox")
If hanDle > 0 Then
SendMessage hanDle, WM_CLOSE, 0, 0

End If

在上面的代码中程序找到标题为About GVBox窗口,然后发送WM_CLOSE.关于API函数,参见VB6.0中Add-in Manager中的VB 6 Api viewer.

7,759

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧