zoukankan      html  css  js  c++  java
  • 急!急!急!请问win32api参数乱码如何解决!

      我想做一个QQ自动登陆,使用的QQ是2009.现在先模拟打开QQ,然后通过api调用回调函数。回调函数为一个委托方法,但是在方法中整个参数乱码,请问如何解决?

      具体流程为,启动QQ,获取当前启动QQ的句柄,通过EnumChildWindows方法回调方法,但是在EnumWindowsProc中,account和pwd乱码。请问如何解决?

            public delegate bool CallBack(IntPtr hwnd, int lParam, string account, string pwd );
    
    
            [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
            static extern IntPtr EnumChildWindows(IntPtr hWndParent, CallBack lpEnumFunc, int lParam);
    
           /// <summary>
            /// QQ登录
            /// </summary>
            public static void LoginIn(string account = "123456", string pwd = "123456")
            {
                //启动QQ程序
                StartCmd();
    
                IntPtr h;
                string strName = "QQ2009";
                h = FindWindow(null, strName);
                if (h.ToInt32() != 0)
                {
                    MoveWindow(h, 0, 0, 350, 300, true);
                    CallBack myCallBack = new CallBack(EnumWindowsProc);
                    EnumChildWindows(h, myCallBack, 0);
                }
            }
    
            /// <summary>
            ///将鼠标移动到登陆按钮
            /// </summary>
            /// <param name="h"></param>
            /// <param name="lParam"></param>
            /// <returns></returns>
            private static bool EnumWindowsProc(IntPtr h, int lParam, string account, string pwd)
            {
                //改变账号
                SetCursorPos(900, 530);
                SetForegroundWindow(h);
                SendMessage(h, 0x000C, IntPtr.Zero, account.ToString());
    
                //移动鼠标到登陆按钮
                SetCursorPos(1090, 645);
                SetForegroundWindow(h);
                mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
                return false;
            }
    

      

  • 相关阅读:
    [Leetcode]@python 65. Valid Number
    二维数组循环求出最大子数组
    一维循环的数组求出最大子数组的和
    电梯调度算法需求分析
    返回一个整数数组中最大子数组的和
    最大子数组求解
    小学数学计算题随机出题软件
    四则运算的设计思路
    学期读书计划
    软件工程概论第十一章
  • 原文地址:https://www.cnblogs.com/zcy-xy/p/4919632.html
Copyright © 2011-2022 走看看