I hace a WPF application and I'm am using the following to obtain the OS details of my PC:
using (ManagementObjectSearcher win32OperatingSystem = new ManagementObjectSearcher("select * from Win32_OperatingSystem"))
{
foreach (ManagementObject obj in win32OperatingSystem.Get())
{
_operatingSystem = obj["Caption"].ToString();
_osArchitecture = obj["OSArchitecture"].ToString();
break;
}
}
WhenI step into this line:
ManagementObject obj in win32OperatingSystem.Get())
I get the following exception:
Invalid Query.
WHat is wrong here??
I would suggest using the properties of the
Environment
andOperatingSystem
class (instead ofManagementObjectSearcher
) to get those details.