Registry

  • Thread starter Thread starter Lou
  • Start date Start date
i wrote a little wrapper that was handy for my use of the registry, maybe
it'll give you an idea as to how to get around. It's working with the HKEY
"LOCALMACHINE", if you want to change it to another HKEY, then just do a
"Find" on "LocalMachine" and change it to whatever other HKEY you want to
access...

using System;
using Microsoft.Win32; // where the reg stuff resides

namespace RegistryStuff
{
public class RegAnalyser
{
public static void SetValue ( string szSubKey, string szName,
string szData )
{
RegistryKey reg;
reg = Registry.LocalMachine.CreateSubKey( szSubKey );
reg.SetValue( szName, szData );
}

public static string GetValue ( string szSubKey, string szName )
{
RegistryKey reg;
reg = Registry.LocalMachine.OpenSubKey ( szSubKey );
if ( reg != null )
return Convert.ToString(reg.GetValue( szName ));
else
return null;
}

public static string[] GetSubKeys ( string szSubKey )
{
RegistryKey reg;
reg = Registry.LocalMachine.OpenSubKey( szSubKey );
if ( reg != null )
return reg.GetSubKeyNames();
else
return null;
}
}
}

if you've got any questions let me know.
Dan.


How do you read and Write to the reg in C#?

-Lou
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top