Ejemplo n.º 1
0
        private void LaunchGame(int index)
        {
            string gwPath = Program.settings.GetPath(index);
            string gwArgs = Program.settings.GetArguments(index);

            //check if the install exists
            if (!File.Exists(gwPath))
            {
                MessageBox.Show("The path: " + gwPath + " does not exist!");
            }
            else
            {
                bool forced = forceUnlockCheckBox.CheckBoxControl.Checked;
                if (forced)
                {
                    HandleManager.ClearDatLock(Directory.GetParent(gwPath).FullName);
                }

                //attempt to launch
                if (LaunchGame(gwPath, gwArgs, forced))
                {
                    //give time for gw to read path before it gets changed again.
                    System.Threading.Thread.Sleep(Program.settings.RegistryCooldown);
                }
            }
        }
Ejemplo n.º 2
0
        public static bool ClearFileLock(string basePath)
        {
            bool success = false;

            //take off the drive portion due to limitation in how killhandle works for file name
            string root = Directory.GetDirectoryRoot(basePath).Substring(0, 2);

            basePath = basePath.Replace(root, string.Empty);

            string fileToUnlock = basePath + "\\" + Program.GW_DAT;

            //get list of currently running system processes
            Process[] processList = Process.GetProcesses();

            foreach (Process i in processList)
            {
                //filter for guild wars ones
                if (i.ProcessName.Equals(Program.GW_PROCESS_NAME, StringComparison.OrdinalIgnoreCase))
                {
                    if (HandleManager.KillHandle(i, fileToUnlock, true))
                    {
                        success = true;
                    }
                }
            }

            return(success);
        }
Ejemplo n.º 3
0
        public static bool LaunchGame(string gwPath, string args, bool forced)
        {
            bool success = false;

            if (!forced)
            {
                //check to see if this copy is already started
                if (IsCopyRunning(gwPath))
                {
                    MessageBox.Show(gwPath + " is already running, please launch a different copy.",
                                    Program.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(success);
                }
            }

            Process gw = new Process();

            gw.StartInfo.FileName         = gwPath;
            gw.StartInfo.Arguments        = args;
            gw.StartInfo.WorkingDirectory = Directory.GetParent(gwPath).FullName;
            gw.StartInfo.UseShellExecute  = true;

            try
            {
                //set new gw path
                RegistryManager.SetGWRegPath(gwPath);

                //clear mutex to allow for another gw launch
                HandleManager.ClearMutex();

                //attempt to start gw process
                gw.Start();

                success = true;
            }
            catch (Exception e)
            {
                MessageBox.Show("Error launching: " + gwPath + "!\n" + e.Message,
                                Program.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(success);
        }
Ejemplo n.º 4
0
        public static bool ClearMutex()
        {
            bool success = false;

            //get list of currently running system processes
            Process[] processList = Process.GetProcesses();

            foreach (Process i in processList)
            {
                //filter for guild wars ones
                if (i.ProcessName.Equals(Program.GW_PROCESS_NAME, StringComparison.OrdinalIgnoreCase))
                {
                    if (HandleManager.KillHandle(i, Program.MUTEX_MATCH_STRING, false))
                    {
                        success = true;
                    }
                }
            }

            return(success);
        }
Ejemplo n.º 5
0
        public static bool LaunchGame(string gwPath, string args, bool forced)
        {
            bool success = false;

            if (!forced)
            {
                //check to see if this copy is already started
                if (IsCopyRunning(gwPath))
                {
                    string errorString = gwPath + " is already running, please launch a different copy";
                    //var response = MessageBox.Show(errorString,
                    //Program.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //if (response == System.Windows.Forms.DialogResult.OK)
                    //{
                    //    System.Windows.Forms.Clipboard.SetDataObject(errorString, true);
                    //}
                    var notification = new NotifyIcon();
                    notification.Visible        = true;
                    notification.Icon           = System.Drawing.SystemIcons.Error;
                    notification.BalloonTipText = errorString;

                    // Display for 5 seconds.
                    notification.ShowBalloonTip(3000);
                    return(success);
                }
            }

            Process gw = new Process();

            gw.StartInfo.FileName         = gwPath;
            gw.StartInfo.Arguments        = args;
            gw.StartInfo.WorkingDirectory = Directory.GetParent(gwPath).FullName;
            gw.StartInfo.UseShellExecute  = true;

            try
            {
                //set new gw path
                RegistryManager.SetGWRegPath(gwPath);

                //clear mutex to allow for another gw launch
                HandleManager.ClearMutex();

                //attempt to start gw process
                gw.Start();

                success = true;
            }
            catch (Exception e)
            {
                string errorString = "Error launching: " + gwPath + "!\n" + e.Message + "trace: " + e.ToString();
                //var response = MessageBox.Show(errorString,
                //Program.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                //if (response == System.Windows.Forms.DialogResult.OK)
                //{
                //    System.Windows.Forms.Clipboard.SetDataObject(errorString, true);
                //}
                exceptionNotification = new NotifyIcon
                {
                    Visible        = true,
                    Icon           = System.Drawing.SystemIcons.Error,
                    BalloonTipText = errorString
                };



                // Display for 5 seconds.
                exceptionNotification.ShowBalloonTip(3000);
                exceptionNotification.Dispose();
                writeLog(errorString);
            }

            gw.Dispose();
            GC.Collect();
            return(success);
        }
Ejemplo n.º 6
0
 private void startTexModButton_Click(object sender, EventArgs e)
 {
     RegistryManager.SetGWRegPath(GetSelectedInstall());
     HandleManager.ClearMutex();
     StartTexMod();
 }
Ejemplo n.º 7
0
 private void killMutexButton_Click(object sender, EventArgs e)
 {
     HandleManager.ClearMutex();
 }