以下vb6代码可以显示((活动窗口的标题栏)):
是否可以找到活动窗口的exe文件名以结束进程?
请查看以下代码的最后一行(示例):
Private Declare Function GetForegroundWindow Lib "user32" () 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 Sub Timer1_Timer()
Dim ActiveWindowHandle As Long
ActiveWindowHandle = GetForegroundWindow()
Dim Title As String * 255
GetWindowText ActiveWindowHandle, Title, Len(Title)
Me.Caption = Trim(Title)
'example: if Me.Caption = "flower" then (end its process)
End Sub