Esempio n. 1
0
 /// <summary>
 /// 判断程序是否改变了位置,并更新位置
 /// </summary>
 private void UpdateAutoOpen()
 {
     //如果程序地址/程序名变更
     if (ConfigureData.configure.EXEPath != Process.GetCurrentProcess().MainModule.FileName)
     {
         //如果是开机启动,需要重新设置
         if (ConfigureData.configure.isAutoOpen)
         {
             //删除原有的开机启动项
             SystemHelper.SetAutoRun(ConfigureData.configure.EXEPath, ConfigureData.configure.EXEName, false);
             //获得新的地址
             //程序地址
             string path = Process.GetCurrentProcess().MainModule.FileName;
             //程序名字
             string name = System.IO.Path.GetFileName(path);
             //重新设置新的开机启动项
             if (!SystemHelper.IsSetAutoRun(path, name))
             {
                 SystemHelper.SetAutoRun(path, name, true);
             }
         }
         //更新EXEPath和EXEName
         ConfigureData.configure.EXEPath = Process.GetCurrentProcess().MainModule.FileName;
         ConfigureData.configure.EXEName = System.IO.Path.GetFileName(ConfigureData.configure.EXEPath);
         //更新XML文档
         ConfigureData.SaveConfigure();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 开机启动
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="value"></param>
        private void uiSwitch_autoOpen_MouseClick(object sender, MouseEventArgs e)
        {
            //程序地址
            string path = Process.GetCurrentProcess().MainModule.FileName;
            //程序名字
            string name = System.IO.Path.GetFileName(path);

            //更新配置表
            ConfigureData.configure.isAutoOpen = uiSwitch_autoOpen.Active;
            ConfigureData.SaveConfigure();
            //设置程序是否自启动
            SystemHelper.SetAutoRun(path, name, uiSwitch_autoOpen.Active);
        }
Esempio n. 3
0
 /// <summary>
 /// 隐藏小图标
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="value"></param>
 private void uiSwitch_hideIcon_MouseClick(object sender, MouseEventArgs e)
 {
     ConfigureData.configure.isHideIcon = uiSwitch_hideIcon.Active;
     //更新XML文档
     ConfigureData.SaveConfigure();
 }