Hi all,
I'm trying to access the registry of a few Windows 98 machines remotely, but I'm
getting a System.NullReferenceException. I know that remote registry access is
enabled because I can connect to the remote machines with Regedit, and of course I've
verified that the key/value I'm looking for actually exists. The same code works for
both Windows 2000 and Windows NT. My code is as follows:
Console.WriteLine(ReadKeyLMAC(@"Software\Microsoft\Internet Explorer", "Version",
"myComputer"));
private string ReadKeyLMAC(string key, string name, string computerName) {
string keyValue="";
try {
RegistryKey regKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine,
computerName);
RegistryKey subKey = regKey.OpenSubKey(key);
// Throws System.NullReferenceException("Object reference not set to instance of
object");
keyValue = subKey.GetValue(name).ToString();
}
return keyValue;
}
In a perhaps related problem, on the same Win98 computers the CreationTime property of
the FileInfoObject returns "1/1/1601" when it should be "9/22/1998" , while the
LastWriteTime property returns valid data.
Has anyone experienced anything similar? Thanks for any ideas!
Bar