Option Explicit
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Const WM_CLOSE = &H10
Private Const GW_HWNDNEXT = 2
Private Const GW_HWNDFIRST = 0
Private WinText As String * 256
Private Handler(200) As IntegerPrivate Sub findrunningprogram()
Dim RenHWND As IntegerDim RetValue As Long
Dim WinTextLength As LongForm1.lststatues.Clear
RenHWND = GetWindow(Form1.hwnd, GW_HWNDNEXT) ' 问题在这里。说“实时错误‘6’并且提示“溢出。”怎么解决”
Do
RetValue = GetWindowText(RenHWND, WinText, 256)
If RetValue <> 0 Then
WinTextLength = GetWindowTextLength(RenHWND)
If Left$(WinText, WinTextLength) <> Form1.Caption And Left$(WinText, WinTextLength) <> App.Title Then
Form1.lststatues.AddItem WinText
Handler(Count) = RenHWNDEnd If
End If
RenHWND = GetWindow(RenHWND, GW_HWNDNEXT)
Loop Until RenHWND = 0
Form1.lststatues.ListIndex = 0End SubPrivate Sub cmdfinsh_Click()
Dim RenValue As Long
RetValue = SendMessage(Handler(Form1.List1.ListIndex), WM_CLOSE, 0, 0)
If RetValue <> 0 Then
MsgBox "清除不成功!"
Else
MsgBox "清除成功!"
End IfEnd SubPrivate Sub Form_Load()
Call findrunningprogram
End SubPrivate Sub Timer1_Timer()
Call findrunningprogram
End Sub
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Const WM_CLOSE = &H10
Private Const GW_HWNDNEXT = 2
Private Const GW_HWNDFIRST = 0
Private WinText As String * 256
Private Handler(200) As IntegerPrivate Sub findrunningprogram()
Dim RenHWND As IntegerDim RetValue As Long
Dim WinTextLength As LongForm1.lststatues.Clear
RenHWND = GetWindow(Form1.hwnd, GW_HWNDNEXT) ' 问题在这里。说“实时错误‘6’并且提示“溢出。”怎么解决”
Do
RetValue = GetWindowText(RenHWND, WinText, 256)
If RetValue <> 0 Then
WinTextLength = GetWindowTextLength(RenHWND)
If Left$(WinText, WinTextLength) <> Form1.Caption And Left$(WinText, WinTextLength) <> App.Title Then
Form1.lststatues.AddItem WinText
Handler(Count) = RenHWNDEnd If
End If
RenHWND = GetWindow(RenHWND, GW_HWNDNEXT)
Loop Until RenHWND = 0
Form1.lststatues.ListIndex = 0End SubPrivate Sub cmdfinsh_Click()
Dim RenValue As Long
RetValue = SendMessage(Handler(Form1.List1.ListIndex), WM_CLOSE, 0, 0)
If RetValue <> 0 Then
MsgBox "清除不成功!"
Else
MsgBox "清除成功!"
End IfEnd SubPrivate Sub Form_Load()
Call findrunningprogram
End SubPrivate Sub Timer1_Timer()
Call findrunningprogram
End Sub
解决方案 »
- 从activex控件与form之间传值
- 程序间信息传递问题
- vb串口控件都支持多少的波特率?
- 高分求解????
- 我有几行VBSCRIPT的代码看不懂,请教!一句是"wscript.exe " + windir+"\aa.vbs"+" ""%2""" 中的%2是什么意思?
- 不知道大家格式化美观源代码用什么?(CodeSMART or SourceFormatX)
- 安装包不能在98 IE 下被安装~~安装包,数字签字达人请进~~~
- VB+Access问题!win2000平台(在VB中写的代码)之二
- 高分求助 马上给分!
- 我数据库中有image这一字段如何在crystal report中显示图片出来,注图片的格式是多种的。
- 看了多年招聘广告后得到的经验,来分享一下
- 关于托盘程序的问题
Dim RenHWND As Long
Dim RenHWND As long