Пример #1
0
        public ProcessInformationDTO GetProcessInformationById(int id)
        {
            WMIProcess wmiProcess = _wmimanagers.WMIProcessManager.GetWMIProcessById(id);

            return(wmiProcess == null? null
                : _mapper.Map <WMIProcess, ProcessInformationDTO>(wmiProcess));
        }
Пример #2
0
        public ProcessInformationDTO GetProcessInformationByName(string name)
        {
            WMIProcess wmiProcess = _wmimanagers.WMIProcessManager.GetWMIProcessByName(name);

            return(wmiProcess == null? null
                : _mapper.Map <WMIProcess, ProcessInformationDTO>(wmiProcess));
        }
Пример #3
0
        private void TimerElapsed(object sender, ElapsedEventArgs e)
        {
            IntPtr handle = Native.GetForegroundWindow();

            if (handle == IntPtr.Zero || handle == thisWindowHandle)
            {
                return;
            }

            int     procId = GetProcessThreadFromWindow(handle);
            Process p      = Process.GetProcessById(procId);

            if (p.MainWindowHandle == IntPtr.Zero || p.MainWindowHandle == thisWindowHandle)
            {
                return;
            }

            string filename;

            CurrentlySelectedWindow = handle;

            try
            {
                filename = p.MainModule.FileName;
            }
            catch
            {
                filename = WMIProcess.GetFilename(procId);
            }

            if (filename != null)
            {
                FileInfo fi = new FileInfo(filename);
                filename = fi.Name;
            }

            StringBuilder sb = new StringBuilder(200);

            Native.GetWindowText(handle, sb, sb.Capacity);
            string title = sb.ToString();

            if (SelectedWindow == null ||
                SelectedWindow.FileName != filename ||
                SelectedWindow.Title != title)
            {
                SelectedWindow.FileName = filename;
                SelectedWindow.Title    = title;
                Dispatcher.Invoke((Action) delegate
                {
                    textBoxApplication.Text       = filename;
                    textBoxWindowTitle.Text       = title;
                    textBoxApplication.CaretIndex = textBoxApplication.Text.Length;
                });
            }
        }