vb编程开发
我要一个关闭代码,vb6.0写的,功能是这样:如果屏幕上有一个软件(不如说:迅雷5),这个代码可以给关闭迅雷5。
答案:首先,建立一个类模块,利用 API察看器程序,将需要用到的常量定义和API函数粘贴过来,如:
Public ConstWM_CLOSE = &H10
Public Const WM_QUIT = &H12
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
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
接下来,就可以利用 FindWindow 函数获取窗口句柄,然后向这个窗口发送 WM_CLOSE 或 WM_QUIT 信息让窗口自行关闭:
Handle = FindWindow("IEFrame", vbNullString)
PostMessage Handle,WM_CLOSE,0,0 或 PostMessage Handle,WM_QUIT,0,0 均可
上一个:vb编程求助
下一个:vb编程问题