private void Initialize(ISWbemObject wbemObj)
        {
            try
            {
                ISWbemObjectPath path = (ISWbemObjectPath)wbemObj.Path_;

                //get the property
                ISWbemPropertySet props = (ISWbemPropertySet)wbemObj.Properties_;
                prop = props.Item(propName, 0);

                if (path.IsClass)
                {
                    genus     = 1;
                    classProp = prop;
                }
                else                    //instance
                {
                    genus     = 2;
                    classProp = ((ISWbemPropertySet)wmiClassObj.Properties_).Item(propName, 0);
                }


                mgmtProp      = mgmtObj.Properties[propName];
                mgmtClassProp = mgmtClassObj.Properties[propName];
            }
            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
            }
        }
        private bool EnumNamespaces(String parent, int num)
        //recursively adds namespaces to the drop-down box
        {
            try
            {
                try
                {
                    wbemServices = wbemLocator.ConnectServer(machineName,
                                                             parent,
                                                             "", "", "", "", 0, null);
                }
                catch (Exception e)
                {
                    //could not connect to the namespace
                    //The most common cause is "Access denied"
                    if (parent.ToLower() == "root")
                    {
                        //could not connect to Root, put error description text in the treeview
                        TreeNode errNode = new TreeNode(e.Message);
                        classList.Nodes.Add(num, errNode);
                    }

                    return(false);
                }

                //show the node
                TreeNode   dummy    = new TreeNode("");
                TreeNode[] children = new TreeNode[] { dummy };
                TreeNode   nsNode   = new TreeNode(parent,
                                                   //(int)schema_icons.SCHEMA_NS_CLOSED,
                                                   //(int)schema_icons.SCHEMA_NS_CLOSED,
                                                   children);

                nsNode.Collapse();
                classList.Nodes.Add(num, nsNode);


                ISWbemObjectSet objSet = wbemServices.InstancesOf("__NAMESPACE", 0, null);

                IEnumerator eInstances = ((IEnumerable)objSet).GetEnumerator();
                while (eInstances.MoveNext())
                {
                    num++;

                    ISWbemObject      obj   = (ISWbemObject)eInstances.Current;
                    ISWbemPropertySet props = (ISWbemPropertySet)obj.Properties_;

                    string NameOut = "";
                    string curName = props.Item("Name", 0).get_Value().ToString();

                    //skip localized namespace
                    //NOTE: this assumes that localized namespaces are always leaf
                    if (curName.ToUpper().IndexOf("MS_", 0) == 0)
                    {
                        continue;
                    }

                    //skip root\security namespace (we don't want to expose it)
                    if (curName.ToUpper() == "SECURITY" && parent.ToUpper() == "ROOT")
                    {
                        continue;
                    }

                    //skip root\directory\ldap namespace (BUGBUG: change this in Beta2 when we can do asynchronous class enumerations)
                    if (curName.ToUpper() == "LDAP" && parent.ToUpper() == "ROOT\\DIRECTORY")
                    {
                        continue;
                    }


                    if (parent != "")
                    {
                        NameOut = parent + "\\" + curName;
                    }
                    else
                    {
                        NameOut = curName;
                    }


                    EnumNamespaces(NameOut, num);
                }

                return(true);
            }
            catch (Exception e)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", e.Message, e.StackTrace));
                return(false);
            }
        }