You can get the description of the value returned by the SetGateWays
method using the ValueMap and Value Qualifiers
.
Try this sample
using System;
using System.Collections.Generic;
using System.Text;
using System.Management;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
List<String> LValues = new List<String>();
List<String> LValuesDesc = new List<String>();
Dictionary<String, String> LValuesDict = new Dictionary<String, String>();
ManagementClass WClass = new ManagementClass("Win32_NetworkAdapterConfiguration");
WClass.Options.UseAmendedQualifiers = true;
foreach (MethodData md in WClass.Methods)
{
if (md.Name.Equals("SetGateways"))
{
//fill a list with the ValuesMap
foreach (QualifierData q in md.Qualifiers)
{
if (q.Name.Equals("ValueMap"))
{
foreach (object Value in ((Array)q.Value))
{
LValues.Add(Convert.ToString(Value));
}
}
}
//fill a list with the Values
foreach (QualifierData q in md.Qualifiers)
{
if (q.Name.Equals("Values"))
{
foreach (object Value in ((Array)q.Value))
{
LValuesDesc.Add(Convert.ToString(Value));
}
}
}
//Merge both lists in a dictionary
for (int i = 0; i <= LValues.Count - 1; i++)
LValuesDict.Add(LValues[i], LValuesDesc[i]);
}
}
//Get the description of some return values
Console.WriteLine(LValuesDict["1"]);
Console.WriteLine(LValuesDict["64"]);
Console.WriteLine(LValuesDict["77"]);
Console.WriteLine(LValuesDict["91"]);
Console.ReadKey();
}
}
}