public static void Main(string[] args) { // 获取二维码 mClient.GetQRCode((sender, Event) => { if (Event.Type == QQActionEventType.EVT_OK) { try { var verify = (QQNotifyEventArgs.ImageVerify)Event.Target; verify.Image.Save("verify.png", System.Drawing.Imaging.ImageFormat.Png); Console.WriteLine("请扫描在项目根目录下qrcode.png图片"); } catch (Exception e) { Console.WriteLine(mClient.Account.QQ + e.StackTrace); } } else { Console.WriteLine("获取二维码失败"); } }); // 检查二维码状态 mClient.CheckQRCode((sender, Event) => { start: Console.WriteLine("checkQRCode " + Event); switch (Event.Type) { case QQActionEventType.EVT_OK: { // 扫描通过,登录成功 mClient.BeginPollMsg(); break; } case QQActionEventType.EVT_ERROR: { var ex = (QQException)(Event.Target); var code = ex.ErrorCode; switch (code) { // 二维码有效,等待用户扫描 // 二维码已经扫描,等用户允许登录 case QQErrorCode.QRCODE_OK: case QQErrorCode.QRCODE_AUTH: Thread.Sleep(3000); // 发现检查二维码状态 goto start; } break; } } }); }