Example #1
0
        private static string processName = "notepad.exe"; // 默认进程名.

        #endregion Fields

        #region Methods

        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                processName = args[0];
            }

            ProcessWatcher procWatcher = new ProcessWatcher(processName);
            procWatcher.ProcessCreated += new ProcessEventHandler(procWatcher_ProcessCreated);
            procWatcher.ProcessDeleted += new ProcessEventHandler(procWatcher_ProcessDeleted);
            procWatcher.ProcessModified += new ProcessEventHandler(procWatcher_ProcessModified);
            procWatcher.Start();

            Console.WriteLine(processName + " 正在被监控...");
            Console.WriteLine("按回车键停止监控...");

            Console.ReadLine();

            procWatcher.Stop();
        }
Example #2
0
        private static string processName = "notepad.exe"; // 默认进程名.

        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                processName = args[0];
            }

            ProcessWatcher procWatcher = new ProcessWatcher(processName);

            procWatcher.ProcessCreated  += new ProcessEventHandler(procWatcher_ProcessCreated);
            procWatcher.ProcessDeleted  += new ProcessEventHandler(procWatcher_ProcessDeleted);
            procWatcher.ProcessModified += new ProcessEventHandler(procWatcher_ProcessModified);
            procWatcher.Start();

            Console.WriteLine(processName + " 正在被监控...");
            Console.WriteLine("按回车键停止监控...");

            Console.ReadLine();

            procWatcher.Stop();
        }
        private static string processName = "notepad.exe"; // Default process name.

        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                processName = args[0];
            }

            ProcessWatcher procWatcher = new ProcessWatcher(processName);

            procWatcher.ProcessCreated  += new ProcessEventHandler(procWatcher_ProcessCreated);
            procWatcher.ProcessDeleted  += new ProcessEventHandler(procWatcher_ProcessDeleted);
            procWatcher.ProcessModified += new ProcessEventHandler(procWatcher_ProcessModified);
            procWatcher.Start();

            Console.WriteLine(processName + " is under watch...");
            Console.WriteLine("Press Enter to stop watching...");

            Console.ReadLine();

            procWatcher.Stop();
        }