[STAThread]
static void Main(string[] args)
{
if (args.Length > 0) // Console Application
{
AttachConsole(-1);
Console.WriteLine("");
Console.WriteLine("Running in console, press ENTER to continue");
Console.ReadLine();
}
else // Windows Application
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
private static extern bool AttachConsole(int pid);