Guys good day. Anyone know other way of retrieving registry entries? rather than using the registry class under win32 namespace?
I have this code in retrieving registry entries under localmachine software key but dang! it takes a lot of time before it finish. any other way to make it fast?
I heard about using API calls but I haven't tried it yet coz I don't see any examples about it.
Thanks in advance.Code:private void LookupSubKeys(string key){ try{ RegistryKey regKey = Registry.LocalMachine.OpenSubKey(key,false); if(regKey.SubKeyCount > 0){ foreach(string sKey in regKey.GetSubKeyNames()){ this.subKey = sKey; this.LookupSubKeys(key + "\\" + subKey); } }else this.ManageGetRegEntry(regKey); }catch(Exception ex){MessageBox.Show(ex.ToString());} } StringBuilder sb = new StringBuilder(); private void ManageGetRegEntry(RegistryKey regKey){ string[] s = regKey.GetValueNames(); foreach(string ss in s){ object value = regKey.GetValue(ss,"Unknown", RegistryValueOptions.DoNotExpandEnvironmentNames); string type = regKey.GetValueKind(ss).ToString(); switch(type){ case "Binary": sb.Append(regKey.ToString()+"~"+subKey+"~"+this.ManageBytes((byte[])value)+"~Binary|"); break; default: sb.Append(regKey.ToString()+"~"+subKey+"~"+string.Format("{0:x2}",value)+"~"+type+"|"); break; } } } private string ManageBytes(byte[] value){ string val = string.Empty; foreach(byte b in value){ val += b.ToString("x2"); } return val; }




Reply With Quote