I am working on a C# application that can take a computer name and connect to that computer over the server and check several of the local security policies and create a log of what policies are incorrectly set. In a nutshell, it is an automated way of going through a security checklist rather than manually looking at each policy at each computer. I am currently trying to read the "Audit Policies" such as "Audit Policy Change" etc. I found a registry key located in HKEY_LOCAL_MACHINE\\Security\\Policy\\PolAdtEv named "(Default)" that is a hexadecimal value that represents the setting of each of the 9 audit policies. Exactly what I need!! There is only one problem. The code below shows how I am trying to read this key. I have read that GetValue("") will read keys named "(Default)," I was also told to try null and "@". I tried all of them and am still having the same problem. ans in the code below always has an undefined value after the GetValue executes. I think the problem is that the (Default) is a REG_NONE type. To test this theory I used the registry editor to copy the (Default) and made it a REG_BINARY and named it "mine." I tried the same code again instead using rk.GetValue("mine"). Now the code works and I get the list of hex numbers that I need to determine the policies. Does anyone know why it will not read the (Default) key Is it because it is a REG_NONE Is there a way around this problem I can't go to each computer and copy this key and change the type each time I want to run the program (well i could but I shouldn't have to). I would appreciate any help you can give. Thanks in advance. Sorry so lengthy.
RegistryKey rk;
string remotename;
remotename = "pc0057963";
string subkey = "Security\\Policy\\PolAdtEv";
rk = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine,remotename)
.OpenSubKey(subkey);
//Print the values.
listBox1.Items.Add("There are " + rk.ValueCount.ToString() + " values for " + rk.Name.ToString() + ".");
//string val = (string)(rk.GetValue(null));
//byte[] ans = (byte[])rk.GetValue("") //ans = <undefined value>
byte[] ans = (byte[])rk.GetValue("mine"); //ans = 01 17 F5 77 03 00 00 00 03..
for(int x=0;x<ans.Length;x++)
{
listBox2.Items.Add(String.Format("{0:x2}",ans[x]));
}

Reading Registry Key
Nanook
RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"Software\MyCompany\DatabaseConfigs\BW10\Connection1");
object value = rk.GetValue("");
System.Console.WriteLine(value);
Jeremy R.
rbshrestha