Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Windows.Forms;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
- class Program
- {
- static void Main(string[] args)
- {
- DialogResult res = Msg("ca pue grave cette histoire..");
- if (res == DialogResult.No)
- LaunchApp("notepad.exe", "Vous etes sur?");
- }
- static DialogResult Msg(string msg)
- {
- return MessageBox.Show(msg, "Message",
- MessageBoxButtons.YesNoCancel);
- }
- [DllImport("User32.dll", EntryPoint = "SendMessage")]
- private static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
- [DllImport("user32.dll", EntryPoint = "FindWindowEx")]
- private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
- static void LaunchApp(string app, string message)
- {
- Process notepad = Process.Start(new ProcessStartInfo("notepad.exe"));
- if (notepad != null)
- {
- notepad.WaitForInputIdle();
- if (!string.IsNullOrEmpty(message))
- {
- IntPtr child = FindWindowEx(notepad.MainWindowHandle, new IntPtr(0), "Edit", null);
- SendMessage(child, 0x000C, 0, message);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement