用 FindWindow怎么得到QQ的窗口

来源:百度知道 编辑:UC知道 时间:2024/06/15 10:45:16
不是聊天窗口,是QQ主窗口

Option Explicit
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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 Command1_Click()
Dim WinHandle As Long, qqWindow As String * 26
Dim ParHandle As Long
Dim Ustr As String
Dim myClassName As String '感谢热心网友修正!

WinHandle = FindWindow(vbNullString, vbNullString) '发现用参数0&,0&得到结果是0,改成这样了
Do While WinHandle <> 0
GetWindowText WinHandle, qqWindow, 26
ParHandle = GetParent(WinHandle)