There's the WMI Code Creator tool from Microsoft that can generate C#, Visual Basic .NET and VBScript code for you to run any WMI query and enumerate the results. It's also very useful for exploring WMI namespaces and classes, so it's a must-have when dealing with WMI.
Now back to the question. From the System.UInt16[]
syntax I assume that you're using C#. Here's sample C# code (generated by WMI Code Creator, with a few minor changes) that demonstrates how you can access individual elements of the Capabilities
array:
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("root\\CIMV2",
"SELECT * FROM Win32_DiskDrive");
foreach (ManagementObject queryObj in searcher.Get())
{
if(queryObj["Capabilities"] == null)
Console.WriteLine("Capabilities: {0}", queryObj["Capabilities"]);
else
{
UInt16[] arrCapabilities = (UInt16[])(queryObj["Capabilities"]);
foreach (UInt16 arrValue in arrCapabilities)
{
Console.WriteLine("Capabilities: {0}", arrValue);
}
}
Console.WriteLine();
}
To convert a UInt16
value to a string, you can use the ToString
method, for example:
foreach (UInt16 arrValue in arrCapabilities)
{
Console.WriteLine(arrValue.ToString());
}