예제 #1
0
        /// <summary>
        /// Checks whether application pool exists
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static bool ApplicationPoolExists(string name)
        {
            WmiHelper wmi = new WmiHelper("root\\MicrosoftIISv2");

            return(wmi.ExecuteQuery(
                       String.Format("SELECT * FROM IIsApplicationPool WHERE Name='W3SVC/AppPools/{0}'", name)).Count > 0);
        }
예제 #2
0
        internal static string[] GetIPv4Addresses()
        {
            List <string> list = new List <string>();
            WmiHelper     wmi  = new WmiHelper("root\\cimv2");
            ManagementObjectCollection collection = wmi.ExecuteQuery("SELECT IPAddress FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = 'True'");

            foreach (ManagementObject obj in collection)
            {
                string[] ips = obj["IPAddress"] as string[];
                if (ips != null)
                {
                    foreach (string ip in ips)
                    {
                        if (!list.Contains(ip) && IsValidIPv4(ip))
                        {
                            list.Add(ip);
                        }
                    }
                }
            }
            return(list.ToArray());
        }