インターネットからこのスニペットを見たばかりですが、うまくいきません。新しいメモ帳アプリケーションを開き、それに「asdf」を追加するとします。
コードに誤りはありませんか?
[DllImport("User32.dll")]
public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, [MarshalAs(UnmanagedType.LPStr)] string lParam);
void Test()
{
const int WM_SETTEXT = 0x000C;
ProcessStartInfo startInfo = new ProcessStartInfo("notepad.exe");
startInfo.UseShellExecute = false;
Process notepad = System.Diagnostics.Process.Start(startInfo);
SendMessage(notepad.MainWindowHandle, WM_SETTEXT, 0, "asdf");
}