我想遍历机器的进程并列出该进程正在使用的所有数据文件。.我并没有获得该进程正在使用的所有文件。
c:\ windows \ system32 \ wow64win.dll,
c:\ windows \ system32 \ wow64cpu.dll,
c:\ windows \ system32 \ wow64.dll
c:\ windows \ system32 \ ntdll.dll。
为什么WMI不在这里列出其他dll ...如果进程资源管理器显示了所有正确的文件。
using (ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Process where ProcessId = 25364"))
{
foreach (ManagementObject mo in searcher.Get())
{
Console.WriteLine("Process Name:",
mo.Properties["Name"].Value);
// Get processes having this File open
var b = mo.GetRelated("CIM_DataFile");
if (b.Count > 0)
{
Console.WriteLine("Stop");
}
}
}