Beispiel #1
0
        } //partial enum, actual set is huge, google SYSTEM_INFORMATION_CLASS

        #endregion

        #region Functions

        /// <summary>
        /// Clears file locks on the GW_DAT file located at basePath.
        /// </summary>
        /// <param name="basePath">Full patch to gw.dat file</param>
        /// <returns></returns>
        public static bool ClearDatLock(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);
        }
Beispiel #2
0
        /// <summary>
        /// Kills GW mutex is active processes.
        /// </summary>
        /// <returns></returns>
        public static bool ClearMutex()
        {
            bool success = false;

            //get list of currently running system processes
            ICollection <Process> processList = Process.GetProcesses().Where(x => x.ProcessName.Equals(Program.GW_PROCESS_NAME, StringComparison.OrdinalIgnoreCase)).ToList();

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

            return(success);
        }