I am working with the WMI Code Creator and the code looks to work properly from the app. HOWEVER, It comes up with errors internal of my code that I cant seem to shake. Am I supposed to have a reference for this to work? if so where can I get it?
public class MyWMIQuery
{
public static void Main()
{
try
{
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2\\Security\\MicrosoftVolumeEncryption",
"SELECT * FROM Win32_EncryptableVolume");
foreach (System.Management.ManagementObject queryObj in searcher.Get())
{
Console.WriteLine("-----------------------------------");
Console.WriteLine("Win32_EncryptableVolume instance");
Console.WriteLine("-----------------------------------");
Console.WriteLine("ProtectionStatus: {0}", queryObj["ProtectionStatus"]);
}
}
catch (ManagementException e)
{
MessageBox.Show("An error occurred while querying for WMI data: " + e.Message);
}
}
}
(click for larger image)