如何在C# Win32中将文本发送到记事本?

如何在C# Win32中将文本发送到记事本?,第1张

如何在C#/ Win32中将文本发送到记事本
    [Dllimport("user32.dll", EntryPoint = "FindWindowEx")]    public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);    [Dllimport("User32.dll")]    public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);    private void button1_Click(object sender, EventArgs e)    {        Process [] notepads=Process.GetProcessesByName("notepad");        if(notepads.Length==0)return;         if (notepads[0] != null)        { IntPtr child= FindWindowEx(notepads[0].MainWindowHandle, new IntPtr(0), "Edit", null); SendMessage(child, 0x000C, 0, textBox1.Text);        }    }

WM_SETTEXT = 0x000c



欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5064106.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-16
下一篇 2022-11-16

发表评论

登录后才能评论

评论列表(0条)

保存