コード例 #1
0
        private void BtMenuAdd_Click(object sender, EventArgs e)
        {
            UICmd("正在读取 全局用户开始菜单启动文件夹");
            string commonStartup = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup);

            UICmd("CommonStartup:" + commonStartup);
            if (ShortcutTool.Create(commonStartup, AppName, AppFile))
            {
                UICmd("添加 全局用户开始菜单启动 成功");
            }
            else
            {
                UICmd("添加 全局用户开始菜单启动 失败");
            }

            UICmd("正在读取 当前用户开始菜单启动文件夹");
            string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup);

            UICmd("Startup:" + startup);
            if (ShortcutTool.Create(startup, AppName, AppFile))
            {
                UICmd("添加 当前用户开始菜单启动 成功");
            }
            else
            {
                UICmd("添加 当前用户开始菜单启动 失败");
            }
        }
コード例 #2
0
ファイル: Main.cs プロジェクト: marcussacana/Social-Savior
        private void StartWindowsClicked(object sender, EventArgs e)
        {
            string Startup = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup);

            if (StartWithWindowsCK.Checked)
            {
                ShortcutTool.Create(Startup, AppName, Application.ExecutablePath, "/Startup", "A Social Media Picture Backuper Tool");
            }
            else
            if (StartupStatus())
            {
                File.Delete(ShortcutTool.GetShortcutPath(Startup, AppName));
            }
        }
コード例 #3
0
ファイル: StartupTool.cs プロジェクト: wangmaogang/Fork
 public static bool Shortcut(string name, string file, bool start = true, bool allUser = true)
 {
     if (start)
     {
         //添加开机启动开始菜单项
         if (allUser)
         {
             if (ShortcutTool.Create(commonStartup, name, file))
             {
                 return(true);
             }
         }
         else
         {
             if (ShortcutTool.Create(startup, name, file))
             {
                 return(true);
             }
         }
     }
     else
     {
         //删除开机启动开始菜单项
         if (allUser)
         {
             if (ShortcutTool.Delete(commonStartup, name))
             {
                 return(true);
             }
         }
         else
         {
             if (ShortcutTool.Delete(startup, name))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
コード例 #4
0
        private void BtMenuDel_Click(object sender, EventArgs e)
        {
            string commonStartup = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup);

            if (ShortcutTool.Delete(commonStartup, AppName))
            {
                UICmd("删除 全局用户开始菜单启动 成功");
            }
            else
            {
                UICmd("删除 全局用户开始菜单启动 失败");
            }

            string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup);

            if (ShortcutTool.Delete(startup, AppName))
            {
                UICmd("删除 当前用户开始菜单启动 成功");
            }
            else
            {
                UICmd("删除 当前用户开始菜单启动 失败");
            }
        }
コード例 #5
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (!File.Exists(@".\splash.png"))
            {
                //Assembly assem = this.GetType().Assembly;
                Assembly assem  = System.Reflection.Assembly.GetEntryAssembly();
                Stream   stream = assem.GetManifestResourceStream("ATEYieldRateStatisticSystem.Resources.Splash.png");
                System.Drawing.Image.FromStream(stream).Save("splash.png");
            }

            SplashForm.StartSplash(@".\splash.png", Color.FromArgb(128, 128, 128));
            //Application.Run (new SplashForm());
            // simulating operations at startup '
            if (!p.checkFolder())
            {
                MessageBox.Show("Create app folder fail,program will exit.", "Create Folder Fail", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                System.Threading.Thread.Sleep(1000);
                SplashForm.CloseSplash();
                Environment.Exit(0);
            }

            if (!File.Exists(@".\IrisSkin4.dll"))
            {
                if (!downloadIrisSkin4())
                {
                    System.Threading.Thread.Sleep(1000);
                    SplashForm.CloseSplash();
                    Environment.Exit(0);
                }
            }


            if (!File.Exists(@".\System.Data.SQLite.dll"))
            {
                if (!downloadSqliteDll())
                {
                    System.Threading.Thread.Sleep(1000);
                    SplashForm.CloseSplash();
                    Environment.Exit(0);
                }
            }

            if (!File.Exists(@".\SQLite.Interop.dll"))
            {
                if (!downloadSqliteInterop())
                {
                    System.Threading.Thread.Sleep(1000);
                    SplashForm.CloseSplash();
                    Environment.Exit(0);
                }
            }

            if (!File.Exists(@".\MySql.Data.dll"))
            {
                if (!downloadMySqlData())
                {
                    System.Threading.Thread.Sleep(1000);
                    SplashForm.CloseSplash();
                    Environment.Exit(0);
                }
            }


            if (!p.checkDB(p.LocalDB))
            {
                System.Threading.Thread.Sleep(1000);
                SplashForm.CloseSplash();
                Environment.Exit(0);
            }



            if (!File.Exists(p.AppFolder + @"\MacOS.ssk"))
            {
                if (!downloadSkin())
                {
                    System.Threading.Thread.Sleep(1000);
                    SplashForm.CloseSplash();
                    Environment.Exit(0);
                }
            }
            //MessageBox.Show(p.AppStart.ToString());

            //check ini file
            if (!File.Exists(p.iniFilePath))
            {
                p.createIniFile(p.iniFilePath);
            }
            p.readIniValue(p.iniFilePath);//exits,read ini file

            p.autoSelectConnstring();



            //create mysql db
            string result = "";

            if (!p.createDB(p.connstringNoDB, out result))
            {
                if (p.AppStart == p.AppStartModel.ATEClient)
                {
                    MessageBox.Show(result + ",the data will record in the local db.");
                }
                if (p.AppStart == p.AppStartModel.YRServer)
                {
                    MessageBox.Show(result + "the program will exit...");
                    System.Threading.Thread.Sleep(1000);
                    SplashForm.CloseSplash();
                    Environment.Exit(0);
                }
            }
            else
            {
                if (!p.createMysqlTable(p.connString, out result))
                {
                    MessageBox.Show(result);
                }
            }

            System.Threading.Thread.Sleep(1000);
            // close the splash screen'
            SplashForm.CloseSplash();

            //創建桌面快捷方式
            //Shortcut.Shortcut.CreateShortcut(Shortcut.Shortcut.GetDeskDir() + "\\ATEYieldRateStatisticSystem.lnk",Application.StartupPath + @"\\ATEYieldRateStatisticSystem", Shortcut.Shortcut.GetDeskDir(), "ATEYieldRateStatisticSystem", AppDomain.CurrentDomain.BaseDirectory + "favicon.ico");
            Shortcut.Shortcut.CreateDesktopShortcut(Application.StartupPath + "\\ATEYieldRateStatisticSystem.lnk", "ATEYieldRateStatisticSystem");

            //創建開機啟動
            //UICmd("正在读取 全局用户开始菜单启动文件夹");
            p.saveLog(DateTime.Now.ToString("HH:mm:ss") + "->" + "正在读取 全局用户开始菜单启动文件夹");
            string commonStartup = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup);

            // UICmd("CommonStartup:" + commonStartup);
            if (ShortcutTool.Create(commonStartup, AppName, AppFile))
            {
                p.saveLog(DateTime.Now.ToString("HH:mm:ss") + "->" + "添加 全局用户开始菜单启动 成功");
            }
            else
            {
                p.saveLog(DateTime.Now.ToString("HH:mm:ss") + "->" + "添加 全局用户开始菜单启动 失败");
            }
            p.saveLog(DateTime.Now.ToString("HH:mm:ss") + "->" + "正在读取 当前用户开始菜单启动文件夹");
            string startup = Environment.GetFolderPath(Environment.SpecialFolder.Startup);

            //UICmd("Startup:" + startup);
            p.saveLog(DateTime.Now.ToString("HH:mm:ss") + "->" + "Startup:" + startup);
            if (ShortcutTool.Create(startup, AppName, AppFile))
            {
                //UICmd("添加 当前用户开始菜单启动 成功");
                p.saveLog(DateTime.Now.ToString("HH:mm:ss") + "->" + "添加 当前用户开始菜单启动 成功");
            }
            else
            {
                //UICmd("添加 当前用户开始菜单启动 失败");
                p.saveLog(DateTime.Now.ToString("HH:mm:ss") + "->" + "添加 当前用户开始菜单启动 失败");
            }



            if (p.AppStart == p.AppStartModel.ATEClient)
            {
                Application.Run(new frmATEClient());
            }
            else if (p.AppStart == p.AppStartModel.YRServer)
            {
                //Application.Run(new frmYRMonitor());
                Application.Run(new frmYROverAll());
            }
            //Application.Run(new frmQueryFR());
            //Application.Run(new frmFTYR());
            //Application.Run(new frmYRbyLine());
            else
            {
                Application.Run(new frmMain());
            }
        }
コード例 #6
0
ファイル: Main.cs プロジェクト: marcussacana/Social-Savior
        private bool StartupStatus()
        {
            string Startup = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup);

            return(File.Exists(ShortcutTool.GetShortcutPath(Startup, AppName)));
        }