ManagementClass mc = new ManagementClass("Win32_ComputerSystem");//实例化 ManagementObjectCollection moc = mc.GetInstances();//获取管理对象集合 foreach (ManagementObject mo in moc) { string st = mo["UserName"].ToString();//用户名 }
时间: 2024-11-05 15:13:18
ManagementClass mc = new ManagementClass("Win32_ComputerSystem");//实例化 ManagementObjectCollection moc = mc.GetInstances();//获取管理对象集合 foreach (ManagementObject mo in moc) { string st = mo["UserName"].ToString();//用户名 }