我想作一個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; }