360进程管理器原理

看了360进程管理器,可以查看正在运行程序所依赖的动态库文件。但是我想把依赖的文件都提取出来,就写了下面的小程序。

        private void button1_Click(object sender, EventArgs e)
        {
            string fileName = "";
            string filePath = "";
            int num = 0;
            foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcessesByName(textBox1.Text))
            {
                foreach(System.Diagnostics.ProcessModule m in p.Modules)
                {
                    
                    fileName = fileName + m.FileName + "\n";
                    //添加过滤条件,提出所需的动态库
                if (m.FileName.ToLower().StartsWith("D:\\DLL\\program"))
                    {
                        filePath = "E:\\dll\\" + Path.GetFileName(m.FileName);
                        File.Copy(m.FileName, filePath, true);

                    }
                }
            }
        }
原文地址:https://www.cnblogs.com/cjingzm/p/2114916.html