private void CheckForRegSoftware(string SubKey, string[] RegSubKeyArray)
 {
     foreach (var item in RegSubKeyArray)
     {
         string          TmpSubKey          = SubKey + @"\" + item;
         CimMethodResult SoftwareData       = SystemSession.InvokeMethod(new CimInstance(RegistryClassName, RegistryNameSpace), "EnumValues", SetRegParameters(RegHives.LOCAL_MACHINE, RegistryMethods.EnumValues, TmpSubKey));
         string[]        SoftWareDataFields = (string[])SoftwareData.OutParameters["sNames"].Value;
         if (SoftWareDataFields != null)
         {
             string DisplayName    = "";
             string DisplayVersion = "";
             foreach (var DataField in SoftWareDataFields)
             {
                 if (DataField == "DisplayName")
                 {
                     CimMethodResult NameResults = SystemSession.InvokeMethod(new CimInstance(RegistryClassName, RegistryNameSpace), "GetStringValue", SetRegParameters(RegHives.LOCAL_MACHINE, RegistryMethods.GetStringValue, TmpSubKey, "DisplayName"));
                     DisplayName = NameResults.OutParameters["sValue"].Value.ToString();
                 }
                 if (DataField == "DisplayVersion")
                 {
                     CimMethodResult VersionResults = SystemSession.InvokeMethod(new CimInstance(RegistryClassName, RegistryNameSpace), "GetStringValue", SetRegParameters(RegHives.LOCAL_MACHINE, RegistryMethods.GetStringValue, TmpSubKey, "DisplayVersion"));
                     DisplayVersion = VersionResults.OutParameters["sValue"].Value.ToString();
                 }
             }
         }
     }
 }
        public void EnumerateBaseSoftwareKeys()
        {
            string          SubKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
            CimMethodResult CimMR  = SystemSession.InvokeMethod(new CimInstance(RegistryClassName, RegistryNameSpace), "EnumKey", SetRegParameters(RegHive.LOCAL_MACHINE, RegistryMethods.EnumKey, SubKey));

            string[] RegSubKeyArray = (string[])CimMR.OutParameters["sNames"].Value;
            if (RegSubKeyArray != null)
            {
                CheckForRegSoftware(SubKey, RegSubKeyArray);
            }
        }
 private void CheckForRegSoftware(string SubKey, string[] RegSubKeyArray)
 {
     foreach (var item in RegSubKeyArray)
     {
         string          TmpSubKey          = SubKey + @"\" + item;
         CimMethodResult SoftwareData       = SystemSession.InvokeMethod(new CimInstance(RegistryClassName, RegistryNameSpace), "EnumValues", SetRegParameters(RegHive.LOCAL_MACHINE, RegistryMethods.EnumValues, TmpSubKey));
         string[]        SoftWareDataFields = (string[])SoftwareData.OutParameters["sNames"].Value;
         if (SoftWareDataFields != null)
         {
             string DisplayName    = "";
             string DisplayVersion = "";
             foreach (var DataField in SoftWareDataFields)
             {
                 if (DataField == "DisplayName")
                 {
                     CimMethodResult NameResults = SystemSession.InvokeMethod(new CimInstance(RegistryClassName, RegistryNameSpace), "GetStringValue", SetRegParameters(RegHive.LOCAL_MACHINE, RegistryMethods.GetStringValue, TmpSubKey, "DisplayName"));
                     DisplayName = NameResults.OutParameters["sValue"].Value.ToString();
                 }
                 if (DataField == "DisplayVersion")
                 {
                     CimMethodResult VersionResults = SystemSession.InvokeMethod(new CimInstance(RegistryClassName, RegistryNameSpace), "GetStringValue", SetRegParameters(RegHive.LOCAL_MACHINE, RegistryMethods.GetStringValue, TmpSubKey, "DisplayVersion"));
                     DisplayVersion = VersionResults.OutParameters["sValue"].Value.ToString();
                 }
             }
             if (DisplayName != "")
             {
                 // Create Software Item on server for enumeration
                 RegAppClass2 RAC = new RegAppClass2();
                 RAC.SubKeyPath     = TmpSubKey;
                 RAC.DisplayName    = DisplayName;
                 RAC.DisplayVersion = DisplayVersion;
                 RegAppUninstallList.Add(RAC);
             }
         }
         RegSoftwareUninstall.Add(item);
     }
 }