Example #1
0
        //用配置信息去同步自启动
        private static void SyncAutoStartState()
        {
            var fact = AutoStarter.IsRegistered(Constants.Identifier, Application.ExecutablePath);
            var conf = config.Get <bool>(ConfigKeys.AutoStart);

            if (fact == conf && !isFirstRun)
            {
                return;
            }

            try
            {
                //可能被杀毒软件阻止
                if (conf)
                {
                    AutoStarter.Register(Constants.Identifier, Application.ExecutablePath);
                }
                else
                {
                    AutoStarter.Unregister(Constants.Identifier);
                }
            }
            catch (Exception)
            {
#if DEBUG
                throw;
#endif
            }
        }