Imports System.Runtime.InteropServices
Imports System.Text
Imports System.Text.RegularExpressions
Imports System.Windows.Forms
Public Class Class1
<DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
Public Shared Function GetClassName(hWnd As IntPtr, lpClassName As StringBuilder, nMaxCount As Integer) As Integer
End Function
<DllImport("user32.dll")>
Private Shared Function IsWindowVisible(hWnd As IntPtr) As Boolean
End Function
<DllImport("user32.dll")>
Private Shared Function IsWindow(hWnd As IntPtr) As Boolean
End Function
Public Shared Function FindAndProcessWindows() As List(Of String)
Dim result As New List(Of String)()
Dim hWnd As IntPtr
Dim className As New StringBuilder(64)
Dim qqclassName As String
For i As Integer = 65535 To 42000000
hWnd = CType(i, IntPtr)
If IsWindow(hWnd) AndAlso Not IsWindowVisible(hWnd) Then
className.Length = 0
If GetClassName(hWnd, className, className.Capacity) <> 0 Then
qqclassName = className.ToString()
If qqclassName.StartsWith("NTQQOpenSdk") OrElse qqclassName.StartsWith("OPENSDK_SHARE2QQ_QQ_WINCLASS") Then
Dim match = Regex.Match(qqclassName, "_(\d+)$")
If match.Success Then
Dim result1 As String = match.Groups(1).Value
result.Add(result1)
End If
End If
End If
End If
Next
Return result
End Function
End Class