示例#1
0
		static void Main()
		{
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);

            UpdateDependencies();

RunAgain:
			try
			{
                //single instance
                using (var mutex = new System.Threading.Mutex(true, FormClipboard.TITLE, out bool result))
                {
                    if (!result)
                    {
                        CenteredMessageBox.MsgBoxErr("Another instance of "+ FormClipboard.TITLE + " is already running.", FormClipboard.TITLE);
                        return;
                    }
                    Application.Run(new FormClipboard());
                }
			}//end try
			catch ( Exception err )
			{
                Utils.Log.WriteLineF("[Main] Exeption: " + err.ToString());

				m_iFailCount++;
                Utils.Log.LogEventErr("Exception(No:" + m_iFailCount + ") in main: " + err.Message);
				if ( m_iFailCount < 4 )
					goto RunAgain;
			}//end catch

            Utils.Log.CloseLog();
		}//end Main
示例#2
0
        private Microsoft.Win32.RegistryKey OpenRegKey(bool writable)
        {
            //const string REG_KEY = @"Software\Microsoft\Windows\CurrentVersion\Run";
            const string REG_KEY = @"SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run";

            try
            {
                return(Microsoft.Win32.Registry.LocalMachine.OpenSubKey(REG_KEY, writable));
            }
            catch (Exception err)
            {
                CenteredMessageBox.MsgBoxErr(err.Message);
                return(null);
            }
        }