using System;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace vmsnet
{

    internal static class Program
    {
        [DllImport("user32.dll")]
        private static extern bool SetProcessDPIAware();

        /// <summary>
        /// 해당 애플리케이션의 주 진입점입니다.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            if (System.Diagnostics.Debugger.IsAttached == false)
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            if (args != null && args.Any()) PUB.ExtCommand = args[0];
            Application.Run(new FMain());
        }

        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            PUB.NotExitMonitor = true;
            string fn = System.IO.Path.Combine("Bugreport", DateTime.Now.ToString("yyMMddHHmmss") + "_error.xml");
            var fi = new System.IO.FileInfo(fn);
            if (fi.Directory.Exists == false) fi.Directory.Create();
            System.IO.File.WriteAllText(fi.FullName, e.ExceptionObject.ToString(), System.Text.Encoding.Default);
        }
    }



}
