RunW3() public static method

public static RunW3 ( ) : bool
return bool
Exemplo n.º 1
0
 static void Main()
 {
     // Initializes the variable that keeps the Warcraft III path.
     Settings.InitPath();
     if (Environment.CommandLine.ToLower().Contains("-launch"))
     {
         Loader.RunW3(); return;
     }
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     Application.Run(new frmMain());
 }
Exemplo n.º 2
0
        /// <summary>
        /// Starts Warcraft III.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">An System.EventArgs that contains no event data.</param>
        private void btnStart_Click(object sender, EventArgs e)
        {
            // Create a dummy to save the path to war3.exe
            string w3path = @"C:\Program Files\Warcraft III\war3.exe";

            // Check if war3.exe exists in the default installation directory.
            if (File.Exists(w3path))
            {
                Loader.RunW3(); // If it does, start Warcraft III!
            }
            else
            {
                // If it doesn't try the registry!
                try // However; Do it safe, it can give an exception, so catch and handle it.
                {
                    // Try to get the value from the registry...
                    w3path = Path.Combine(Registry.CurrentUser.OpenSubKey(@"Software\Blizzard Entertainment\Warcraft III").GetValue("InstallPath").ToString(), "war3.exe");
                }
                catch (Exception)
                {
                    // Seems like it gave an error, let the user find it for himself...
                    MessageBox.Show("An exception was thrown while getting the installation path from the registry. Please select the location of war3.exe manually.",
                                    "Registry exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    // Create a new form that will help your users to find war3.exe.
                    OpenFileDialog ofd = new OpenFileDialog();
                    ofd.Filter           = "Executable files|*.exe|All files|*.*"; // Create a filter that will only allow extensions like: *.exe or everything else. (*.*).
                    ofd.RestoreDirectory = true;
                    if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        w3path = ofd.FileName;
                    }
                }
                // Check for war3.exe once more, if it doesn't give a message and exit the method.
                if (File.Exists(w3path))
                {
                    Loader.RunW3();
                }
                else
                {
                    MessageBox.Show("war3.exe was nowhere to find, please retry by pressing the Start Warcraft III button.", "No war3.exe", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }