示例#1
0
        /// <summary>
        /// Returns the MapInfo process that wasn't running already when the tool started
        /// </summary>
        /// <param name="miProcs"></param>
        /// <returns></returns>
        private Process GetMapInfoProcess(Process[] miProcs)
        {
            if (miProcs == null) return null;
            var q = Process.GetProcesses().Where(p => (Regex.IsMatch(p.ProcessName, "MapInfow", RegexOptions.IgnoreCase)) &&
                (p.MainWindowHandle != IntPtr.Zero)).Where(p => (miProcs.Count(mip => mip.Id == p.Id) == 0));

            if (q.Count() == 1)
            {
                Process miProcess = q.ElementAt(0);
                if (miProcess.MainModule.FileName == _mapInfoApp.FullName)
                    return miProcess;
            }
            return null;
        }
        private void refreshEmacsProcess(out Process[] emacs_processes, out List<Process> processes_opened)
        {
            emacs_processes = Process.GetProcessesByName("emacs");
            processes_opened = new List<Process>();

            if (emacs_processes.Count() > 0)
            {
                foreach (Process process_cur in emacs_processes)
                {
                    if (process_cur.MainModule.FileName == Program.Root_path + "\\" + FileManager.EMACS_PATH)
                    {
                        processes_opened.Add(process_cur);
                    }
                }
            }
        }