[C#] 纯文本查看 复制代码
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
[DllImport("user32.dll")] // 窗口是否可见
private static extern bool IsWindowVisible(IntPtr hWnd);
[DllImport("user32.dll")] // 窗口句柄是否有效
private static extern bool IsWindow(IntPtr hWnd);
void Main() //
{
IntPtr hWnd;
StringBuilder className = new StringBuilder(64);
string qqclassName;
for (int i = 1000000; i <= 9000000; i++)
{
hWnd = (IntPtr)i;
if (IsWindow(hWnd) && !IsWindowVisible(hWnd))
{
if (GetClassName(hWnd, className, className.Capacity) != 0)
{
qqclassName = className.ToString();
if (qqclassName.StartsWith("NTQQOpenSdk"))
{
Console.WriteLine($"窗口句柄ID:{hWnd.ToInt64()} === \t{qqclassName}");
var match = Regex.Match(qqclassName, @"_(\d+)$");
if (match.Success)
{
string result1 = match.Groups[1].Value;
Console.WriteLine(result1);
}
// return;
}
}
}
}
} |