Beispiel #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();
        }