using System;
using System.Reflection;
using System.Windows.Forms;

namespace RyLine
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            // 修改 EWX_SHUTDOWN 或者 EWX_LOGOFF, EWX_REBOOT等实现不同得功能。
            // 在XP下可以看到帮助信息，以得到不同得参数
            // SHUTDOWN /?
            Init.Run(args);
            //shoutdown.DoExitWin(shoutdown.EWX_SHUTDOWN + shoutdown.EWX_FORCE);
            //Application.Run(new Form1());
        }
        static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
        {
            try
            {
                AssemblyName assemblyName = new AssemblyName(args.Name);
                if (System.IO.File.Exists(Application.StartupPath + @"\Bin\dlls\" + assemblyName.Name + ".dll"))
                {
                    return Assembly.LoadFrom(Application.StartupPath + @"\Bin\dlls\" + assemblyName.Name + ".dll");
                }
                else
                {
                    return args.RequestingAssembly;
                }
            }
            catch (Exception ex)
            {
                return args.RequestingAssembly;
            }
        }
    }
}
