[DllImport("User32.dll")]
 public static extern int SendMessage(IntPtr Hwnd, int Msg, int  wpala, string  lpala);
我用findwindowex已经找到记事本文本的窗口句柄,发送char类型的英文已经实现,但是怎么发送中文啊?
用string类型为啥没反应额..查了下网上说要用SendMessage+WM_SETTEXT,请问给下代码怎么具体操作的,感激不敬...

解决方案 »

  1.   

    为什么不用.net封装好的 SendKey?
      

  2.   

    SendKeys..::.Send 方法 
    向活动应用程序发送击键。下面是一个示例: // Clicking Button1 causes a message box to appear.
    private void Button1_Click(System.Object sender, System.EventArgs e)
    {
    MessageBox.Show("Click here!");
    }        //窗体上只有一个按钮时,默认加载后,button1处于焦点状态,所以下面会触发Button1_Click
    private void Form1_DoubleClick(object sender, System.EventArgs e)
    { // Send the enter key; since the tab stop of Button1 is 0, this
    // will trigger the click event.
    SendKeys.Send("{ENTER}");
    }
      

  3.   

    晕,sendkeys先要把记事本激活取得焦点,我现在要用SendMessage
      

  4.   

    你自己已经说对了。
    发送 wm_settext 而不是 wm_char
      

  5.   

    不是啊,wm_settext发送string可以?private const int WM_GETTEXT = 0x000D;
    [DllImport("User32.dll")]
    public static extern int SendMessage(IntPtr Hwnd, int Msg, string wpala, int lpala);
    SendMessage(ChildWnd, WM_GETTEXT,"asdasdasda", 0);
    ChildWnd已经取到,但是这样还是发不出去的
      

  6.   

    你发送的是 WM_GETTEXT 
      

  7.   

    private const int WM_SETTEXT = 0x000C;
    [DllImport("User32.dll")]
    public static extern int SendMessage(IntPtr Hwnd, int Msg, string wpala, int lpala); 
    SendMessage(ChildWnd, WM_SETTEXT, "asdasdasda", 0);
    这样还是不行....
      

  8.   

    WM_SETTEXT Message
    An application sends a WM_SETTEXT message to set the text of a window. Parameters
    wParam
    This parameter is not used. lParam
    Pointer to a null-terminated string that is the window text. 
    是lParam为字符串。