Results 1 to 2 of 2

Thread: Fastest way to retrieve registry entries.

  1. #1

    Thread Starter
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Fastest way to retrieve registry entries.

    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.

    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;
            }
    Thanks in advance.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Fastest way to retrieve registry entries.

    Perhaps this article might help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width