Advertisement
Cafouillage

code

Sep 19th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. using System;
  2. using System.Windows.Forms;
  3. using System.Diagnostics;
  4. using System.Runtime.InteropServices;
  5.  
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. DialogResult res = Msg("ca pue grave cette histoire..");
  11. if (res == DialogResult.No)
  12. LaunchApp("notepad.exe", "Vous etes sur?");
  13. }
  14.  
  15. static DialogResult Msg(string msg)
  16. {
  17. return MessageBox.Show(msg, "Message",
  18. MessageBoxButtons.YesNoCancel);
  19. }
  20.  
  21. [DllImport("User32.dll", EntryPoint = "SendMessage")]
  22. private static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
  23. [DllImport("user32.dll", EntryPoint = "FindWindowEx")]
  24. private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
  25.  
  26. static void LaunchApp(string app, string message)
  27. {
  28. Process notepad = Process.Start(new ProcessStartInfo("notepad.exe"));
  29. if (notepad != null)
  30. {
  31. notepad.WaitForInputIdle();
  32.  
  33. if (!string.IsNullOrEmpty(message))
  34. {
  35. IntPtr child = FindWindowEx(notepad.MainWindowHandle, new IntPtr(0), "Edit", null);
  36. SendMessage(child, 0x000C, 0, message);
  37. }
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement