#define hoge using System; using System.Collections.Generic; using System.Text; using System.Management; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { #if hoge ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\MicrosoftIISv2", "SELECT Name, ServerComment, ServerBindings FROM IIsWebServerSetting"); #else ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\MicrosoftIISv2", "SELECT * FROM IIsWebServerSetting"); #endif ManagementObjectCollection collection = searcher.Get(); foreach (ManagementObject ite in collection) { #if hoge Console.WriteLine("----------------------------------------"); Console.WriteLine(ite["Name"]); Console.WriteLine(ite["ServerComment"]); ManagementBaseObject[] arr = (ManagementBaseObject[])ite["ServerBindings"]; Console.WriteLine(arr.Length); foreach (ManagementBaseObject mbo in arr) { Console.WriteLine("\t-----"); foreach (PropertyData pd in mbo.Properties) { Console.WriteLine("\t" + pd.Name + ", " + pd.Value); } } #else foreach (PropertyData ite2 in ite.Properties) { Console.WriteLine(ite2.Name + ", " + ite2.Value); } break; #endif } } } }