急!急!急!请问win32api参数乱码如何解决!

  我想作一个QQ自动登录,使用的QQ是2009.如今先模拟打开QQ,而后经过api调用回调函数。回调函数为一个委托方法,可是在方法中整个参数乱码,请问如何解决?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;
        }
相关文章
相关标签/搜索