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

            if ((args.Length != 1) && (args.Length != 2))
            {
                ShowUsageAndQuit();
            }
            if (args.Length == 2)
            {
                if (args[1] == "/Q")
                {
                    _quietMode = true;
                }
                else
                {
                    ShowUsageAndQuit();
                }
            }
            _filenameOrUrl = args[0];

            Awesomium.Core.WebConfig config = new Awesomium.Core.WebConfig();
            Awesomium.Core.WebCore.Initialize(config);

            _timeoutTimer          = new System.Windows.Forms.Timer();
            _timeoutTimer.Interval = 5000; // We wait this long before giving up (in case there is no DocumentReady)
            _timeoutTimer.Tick    += new EventHandler(_timeoutTimer_Tick);
            _timeoutTimer.Enabled  = true;

            _startTimer          = new System.Windows.Forms.Timer();
            _startTimer.Interval = 1;
            _startTimer.Tick    += new EventHandler(_startTimer_Tick);
            _startTimer.Enabled  = true;

            Application.Run();
        }
示例#2
0
文件: Program.cs 项目: jlami/mutefm
        static void Main(string[] args)
        {
            /*
            if (System.DateTime.Compare(DateTime.Now, new DateTime(MuteFm.Constants.ExpireYear, MuteFm.Constants.ExpireMonth, MuteFm.Constants.ExpireDay, 23, 59, 59, DateTimeKind.Utc)) > 0)
            {
                MessageBox.Show("This version of mute.fm is beta software and has expired.  Thanks for demoing!  Get a new version at http://www.mute.fm/");
                return;
            }*/

            MuteFm.SmartVolManagerPackage.SoundEventLogger.LogMsg(Constants.ProgramName + " loaded!");

            if (System.Environment.CommandLine.ToUpper().Contains("FIRSTTIME"))
                FirstTime = true;

            if (System.Environment.CommandLine.ToUpper().Contains("SERVICE"))
                IsService = true;

            if ((args.Length > 0) && (args[0].ToUpper().Contains("INTERNALBUILDMODE")))
                InternalBuildMode = true;

            // Initialize Awesomium (the browser control)
            /*            if (Awesomium.Core.WebCore.IsChildProcess)
            {
                Awesomium.Core.WebCore.ChildProcessMain();
                return;
            }*/
            #if !NOAWE
            Awesomium.Core.WebConfig config = new Awesomium.Core.WebConfig();
            //            config.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.17 Safari/537.36";
            //TODO-AWE config.EnableDatabases = true;
            //TODO-AWE config.SaveCacheAndCookies = true;
            //config.LogLevel = Awesomium.Core.LogLevel.Verbose;

            #if !DEBUG
            config.LogLevel = Awesomium.Core.LogLevel.None;
            #else
            config.LogLevel = Awesomium.Core.LogLevel.Normal;
            #endif
            if (!InternalBuildMode)
            {
                string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                config.ChildProcessPath = path  +"/mute_fm_web";
                //TODO-AWE config.ChildProcessPath = Awesomium.Core.WebConfig.CHILD_PROCESS_SELF;
            }
            Awesomium.Core.WebCore.Initialize(config);
            #endif
            // get application GUID as defined in AssemblyInfo.cs
            string appGuid = ((GuidAttribute)System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value.ToString();

            // unique id for global mutex - Global prefix means it is global to the machine
            string mutexId = string.Format("Global\\{{{0}}}", appGuid);

            using (var mutex = new Mutex(false, mutexId))
            {
                // note: some of this is Windows-only

                // edited by Jeremy Wiebe to add example of setting up security for multi-user usage
                // edited by 'Marc' to work also on localized systems (don't use just "Everyone")
                var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow);
                var securitySettings = new MutexSecurity();
                securitySettings.AddAccessRule(allowEveryoneRule);
                mutex.SetAccessControl(securitySettings);

                //edited by acidzombie24
                var hasHandle = false;
                try
                {
                    try
                    {
                        // note, you may want to time out here instead of waiting forever
                        //edited by acidzombie24
                        //mutex.WaitOne(Timeout.Infinite, false);
                        hasHandle = mutex.WaitOne(500, false); // was 5000 here

                        // We just show a UI here
                        if (hasHandle == false)
                        {
                            //MessageBox. Show(Constants.ProgramName + " is already running.  You can access it via the system tray.");
                            MuteFm.UiPackage.PlayerForm playerForm = new UiPackage.PlayerForm();
                            playerForm.Show();
                            playerForm.Init(true);
                            Application.Run(playerForm);
                            Environment.Exit(0);

                            //MessageBox. Show(Constants.ProgramName + " is already running.  You can access it via the system tray or the " + Constants.ProgramName + " Google Chrome extension.");
                            //Environment.Exit(1);
                            //throw new TimeoutException("Timeout waiting for exclusive access");
                        }
                    }
                    catch (AbandonedMutexException)
                    {
                        // Log the fact the mutex was abandoned in another process, it will still get aquired
                        hasHandle = true;
                    }

                    // Perform your work here.
                    Init(args);
                }
                finally
                {
                    //edit by acidzombie24, added if statemnet
                    if (hasHandle)
                        mutex.ReleaseMutex();
                }

                //SmartVolManagerPackage.SoundServer.RestoreVolumes();
                Environment.Exit(0);
            }
        }
示例#3
0
文件: Program.cs 项目: rootkow/mutefm
        static void Main(string[] args)
        {
            /*
             * if (System.DateTime.Compare(DateTime.Now, new DateTime(MuteFm.Constants.ExpireYear, MuteFm.Constants.ExpireMonth, MuteFm.Constants.ExpireDay, 23, 59, 59, DateTimeKind.Utc)) > 0)
             * {
             *  MessageBox.Show("This version of mute.fm is beta software and has expired.  Thanks for demoing!  Get a new version at http://www.mutefm.com/");
             *  return;
             * }*/

            MuteFm.SmartVolManagerPackage.SoundEventLogger.LogMsg(Constants.ProgramName + " loaded!");

            if (System.Environment.CommandLine.ToUpper().Contains("FIRSTTIME"))
            {
                FirstTime = true;
            }

            if (System.Environment.CommandLine.ToUpper().Contains("SERVICE"))
            {
                IsService = true;
            }

            if ((args.Length > 0) && (args[0].ToUpper().Contains("INTERNALBUILDMODE")))
            {
                InternalBuildMode = true;
            }

            // Initialize Awesomium (the browser control)

/*            if (Awesomium.Core.WebCore.IsChildProcess)
 *          {
 *              Awesomium.Core.WebCore.ChildProcessMain();
 *              return;
 *          }*/
#if !NOAWE
            Awesomium.Core.WebConfig config = new Awesomium.Core.WebConfig();
//            config.UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.17 Safari/537.36";
            //TODO-AWE config.EnableDatabases = true;
            //TODO-AWE config.SaveCacheAndCookies = true;
            //config.LogLevel = Awesomium.Core.LogLevel.Verbose;

#if !DEBUG
            config.LogLevel = Awesomium.Core.LogLevel.None;
#else
            config.LogLevel = Awesomium.Core.LogLevel.Normal;
#endif
            if (!InternalBuildMode)
            {
                string path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                config.ChildProcessPath = path + "/mute_fm_web";
                //TODO-AWE config.ChildProcessPath = Awesomium.Core.WebConfig.CHILD_PROCESS_SELF;
            }
            Awesomium.Core.WebCore.Initialize(config);
#endif
            // get application GUID as defined in AssemblyInfo.cs
            string appGuid = ((GuidAttribute)System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value.ToString();

            // unique id for global mutex - Global prefix means it is global to the machine
            string mutexId = string.Format("Global\\{{{0}}}", appGuid);

            using (var mutex = new Mutex(false, mutexId))
            {
                // note: some of this is Windows-only

                // edited by Jeremy Wiebe to add example of setting up security for multi-user usage
                // edited by 'Marc' to work also on localized systems (don't use just "Everyone")
                var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow);
                var securitySettings  = new MutexSecurity();
                securitySettings.AddAccessRule(allowEveryoneRule);
                mutex.SetAccessControl(securitySettings);

                //edited by acidzombie24
                var hasHandle = false;
                try
                {
                    try
                    {
                        // note, you may want to time out here instead of waiting forever
                        //edited by acidzombie24
                        //mutex.WaitOne(Timeout.Infinite, false);
                        hasHandle = mutex.WaitOne(500, false); // was 5000 here

                        // We just show a UI here
                        if (hasHandle == false)
                        {
                            //MessageBox. Show(Constants.ProgramName + " is already running.  You can access it via the system tray.");
                            MuteFm.UiPackage.PlayerForm playerForm = new UiPackage.PlayerForm();
                            playerForm.Show();
                            playerForm.Init(true);
                            Application.Run(playerForm);
                            Environment.Exit(0);

                            //MessageBox. Show(Constants.ProgramName + " is already running.  You can access it via the system tray or the " + Constants.ProgramName + " Google Chrome extension.");
                            //Environment.Exit(1);
                            //throw new TimeoutException("Timeout waiting for exclusive access");
                        }
                    }
                    catch (AbandonedMutexException)
                    {
                        // Log the fact the mutex was abandoned in another process, it will still get aquired
                        hasHandle = true;
                    }

                    // Perform your work here.
                    Init(args);
                }
                finally
                {
                    //edit by acidzombie24, added if statemnet
                    if (hasHandle)
                    {
                        mutex.ReleaseMutex();
                    }
                }

                //SmartVolManagerPackage.SoundServer.RestoreVolumes();
                Environment.Exit(0);
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if ((args.Length != 1) && (args.Length != 2))
            {
                ShowUsageAndQuit();
            }
            if (args.Length == 2)
            {
                if (args[1] == "/Q")
                    _quietMode = true;
                else
                    ShowUsageAndQuit();
            }
            _filenameOrUrl = args[0];

            Awesomium.Core.WebConfig config = new Awesomium.Core.WebConfig();
            Awesomium.Core.WebCore.Initialize(config);

            _timeoutTimer = new System.Windows.Forms.Timer();
            _timeoutTimer.Interval = 5000; // We wait this long before giving up (in case there is no DocumentReady)
            _timeoutTimer.Tick += new EventHandler(_timeoutTimer_Tick);
            _timeoutTimer.Enabled = true;

            _startTimer = new System.Windows.Forms.Timer();
            _startTimer.Interval = 1;
            _startTimer.Tick += new EventHandler(_startTimer_Tick);
            _startTimer.Enabled = true;

            Application.Run();
        }