-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: G�rard EDMOND
Message 2 in Discussion
Hi, Given is a sample (on C#) which makes registry access. Hope this might help u to
kick start. Get in touch in case of clarifications.
public class RegOper
{
public RegOper()
{
//
// TODO: Add constructor logic here
//
}
public static string SEPARATOR = "\\" ;
public static string HKEY_LOCAL_MACHINE = "HKEY_LOCAL_MACHINE" ;
/* Fetches values from System Registry */
public static String getRegistryValue(string registryKey)
{
int startParamIndex ;
string registryNodekeyName ;
string registryLeafName ;
startParamIndex = registryKey.LastIndexOf(SEPARATOR) ;
registryNodekeyName = registryKey.Substring(0,startParamIndex) ;
registryLeafName = registryKey.Substring(startParamIndex+1) ;
return getRegistryValue(registryNodekeyName,registryLeafName) ;
}
/* Fetches values from System Registry */
public static String getRegistryValue(string registryKey, string paramName)
{
RegistryKey rootRegistry = null ;
RegistryKey finalKey ;
int index ;
string keyName ;
string result = "";
if (registryKey.StartsWith(HKEY_LOCAL_MACHINE))
{
rootRegistry = Registry.LocalMachine ;
}
if ( rootRegistry == null)
{
//throw new InvalidRegistryKeyException() ;
return result ;
}
index = registryKey.IndexOf(SEPARATOR) ;
index = index+SEPARATOR.Length ;
keyName = registryKey.Substring(index) ;
finalKey = rootRegistry.OpenSubKey(keyName) ;
result = (string)finalKey.GetValue(paramName) ;
return result ;
}
/* Fetches values from System Registry */
public static Hashtable getRegistryValueAsList(string registryKey)
{
RegistryKey rootRegistry = null ;
RegistryKey finalKey ;
int index ;
string keyName ;
Hashtable result ;
string []keyNames ;
if (registryKey.StartsWith(HKEY_LOCAL_MACHINE))
{
rootRegistry = Registry.LocalMachine ;
}
if ( rootRegistry == null)
{
//throw new InvalidRegistryKeyException() ;
result = new Hashtable() ;
return result;
}
index = registryKey.IndexOf(SEPARATOR) ;
index = index+SEPARATOR.Length ;
keyName = registryKey.Substring(index) ;
finalKey = rootRegistry.OpenSubKey(keyName) ;
finalKey.GetValueNames() ;
keyNames = finalKey.GetValueNames() ;
result = new Hashtable() ;
foreach(string paramName in keyNames)
{
string paramValue = (string)finalKey.GetValue(paramName) ;
result.Add(paramName,paramValue) ;
}
return result ;
}
}
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]