Exemplo n.º 1
0
        static void Main()
        {
            string applicationName = Application.ProductName;
            string executablePath  = Application.ExecutablePath;

            int[] portsToOpen = { };
            //hnetcfg.dll
            Firewall.OpenFirewallPorts(executablePath, applicationName, portsToOpen);

            QualityAgentLogger Logger = new QualityAgentLogger(Application.StartupPath + @"\QualityAgent.exe");

            Console.SetError(Logger);

            //Allow to run only one instance of application

            // A boolean that indicates whether this application has
            // initial ownership of the Mutex.
            bool ownsMutex;

            // Attempt to create and take ownership of a Mutex named
            // MutexExample.
            using (Mutex mutex =
                       new Mutex(true, "Remwave-Client-Mutex", out ownsMutex))
            {
                // If the application owns the Mutex it can continue to execute;
                // otherwise, the application should exit.
                if (ownsMutex)
                {
                    Console.WriteLine("Mutex:Started Client-Mutex to ensure only one instance run concurrently.");
                    Application.EnableVisualStyles();
                    AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
                    Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
                    Application.SetCompatibleTextRenderingDefault(false);

                    //Splash screen
                    Thread thread = new Thread(new ThreadStart(Program.DoSplash));
                    thread.Priority = ThreadPriority.Normal;
                    thread.Start();
                    try
                    {
                        Form MainForm = new ClientForm();
                        MainForm.Show();
                        msShowSplash = false;
                        Application.Run(MainForm);
                    }
                    catch (Exception ex)
                    {
                        HandleException(ex);
                    }

                    // Release the mutex
                    mutex.ReleaseMutex();
                }
                else
                {
                    Console.WriteLine("Mutex:Another instance is already running. This instance of the application will terminate.");
                    Thread.Sleep(1000);
                }
            }
        }
Exemplo n.º 2
0
        ///
        /// Deletes the firewall ports specified from the windows firewall exclusions list. Also deletes
        /// the given application from the excluded apps.
        ///
        /// The path of the application. Please include the ending \
        /// The name of the executable to close
        /// The ports that you wish to close individually
        public static void CloseFirewallPorts(string executableFilePath, string applicationName, int[] portsToClose)
        {
            Firewall fw = new Firewall();

            fw.closeFirewall(executableFilePath, applicationName, portsToClose);
        }
Exemplo n.º 3
0
 ///
 /// Deletes the firewall ports specified from the windows firewall exclusions list. Also deletes
 /// the given application from the excluded apps.
 ///
 /// The path of the application. Please include the ending \
 /// The name of the executable to close
 /// The ports that you wish to close individually
 public static void CloseFirewallPorts(string executableFilePath, string applicationName, int[] portsToClose)
 {
     Firewall fw = new Firewall();
     fw.closeFirewall(executableFilePath, applicationName, portsToClose);
 }
Exemplo n.º 4
0
        ///
        /// Opens the given ports on windows firewall. Also opens entirely the given application on the firewall.
        /// Please remember that you need administrative rights to use this function.
        ///
        /// The path of the application. Please include the ending \
        /// The name of the executable to open
        /// The ports that you wish to open individually
        public static void OpenFirewallPorts(string executableFilePath, string applicationName, int[] portsToOpen)
        {
            Firewall fw = new Firewall();

            fw.openFirewall(executableFilePath, applicationName, portsToOpen);
        }
Exemplo n.º 5
0
 ///
 /// Opens the given ports on windows firewall. Also opens entirely the given application on the firewall.
 /// Please remember that you need administrative rights to use this function.
 ///
 /// The path of the application. Please include the ending \
 /// The name of the executable to open
 /// The ports that you wish to open individually
 public static void OpenFirewallPorts(string executableFilePath, string applicationName, int[] portsToOpen)
 {
     Firewall fw = new Firewall();
     fw.openFirewall(executableFilePath, applicationName, portsToOpen);
 }