本帖最后由 zmoli775 于 2025-4-10 17:22 编辑
[C#] 纯文本查看 复制代码 [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] // 窗口是否可见
private static extern bool IsWindowVisible(IntPtr hWnd);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] // 窗口句柄是否有效
private static extern bool IsWindow(IntPtr hWnd);
void Main()
{
Task findtask = Task.Run(() => { FindLoginQQ(65565 + 1, 65565 * 100); });
Task.WaitAll(findtask);
Console.WriteLine("执行完毕...");
}
void FindLoginQQ(int s, int e)
{
IntPtr hWnd; StringBuilder className = new StringBuilder(64); string qqclassName; long hWndId;
for (int i = s; i <= e; i++)
{
hWnd = (IntPtr)i; hWndId = hWnd.ToInt64();
if (IsWindow(hWnd) && !IsWindowVisible(hWnd) && hWndId > s && hWndId < e)
{
className.Length = 0;
int len = GetClassName(hWnd, className, className.Capacity);
if (len != 0 && len > 25 && len <= 65)
{
qqclassName = className.ToString(); //Console.WriteLine(qqclassName);
if (qqclassName.StartsWith("NTQQOpenSdk") || qqclassName.StartsWith("OPENSDK_SHARE2QQ_QQ_WINCLASS") /*|| qqclassName.StartsWith("OPENSDK_AUTH_IPC_CLASS_QQ")*/)
{
Console.WriteLine($"窗口句柄:{hWnd.ToInt64()} = 窗口类名:{qqclassName} 长度:{qqclassName.Length}");
var match = Regex.Match(qqclassName, @"_(\d+)$");
if (match.Success)
{
string result1 = match.Groups[1].Value; Console.WriteLine($"获取号码:{result1}");
}
}
}
}
}
} |