Guest User

C# external tool for SSMS - Reading from stdin

a guest
Feb 27th, 2012
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. class Program : WindowsFormsApplicationBase
  2. {
  3. static Form1 mainForm = null;
  4.  
  5. /// <summary>
  6. /// The main entry point for the application.
  7. /// </summary>
  8. [STAThread]
  9. static void Main(string[] commandline)
  10. {
  11. Application.EnableVisualStyles();
  12. Application.SetCompatibleTextRenderingDefault(false);
  13. Program prog = new Program();
  14. prog.MainForm = mainForm = new Form1();
  15. prog.Run(commandline);
  16. }
  17.  
  18. public Program()
  19. {
  20. this.IsSingleInstance = true;
  21. }
  22.  
  23. protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
  24. {
  25. base.OnStartupNextInstance(eventArgs);
  26. mainForm.Startup(eventArgs.CommandLine.ToArray());
  27. }
  28. }
  29.  
  30. public void Startup(string[] commandLine)
  31. {
  32. string output = "";
  33. foreach (string arg in commandLine)
  34. output += arg + "n";
  35.  
  36. label1.Text = output;
  37. }
  38.  
  39. public Form1()
  40. {
  41. InitializeComponent();
  42. Startup(Environment.GetCommandLineArgs());
  43. }
Add Comment
Please, Sign In to add comment