Want more features on Pastebin? Sign Up, it's FREE!
Guest

C# external tool for SSMS - Reading from stdin

By: a guest on Feb 27th, 2012  |  syntax: None  |  size: 1.03 KB  |  views: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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.     }
clone this paste RAW Paste Data