The same thing is still happening. (The object reference not set to an instance of an object).
Here's the entire program once again:
using System;
using System.IO;
using Microsoft.Win32;
using System.Text;
using System.Diagnostics;
using System.Data;
using System.Collections.Generic;
using System.ComponentModel;
class Test
{
public static void Main()
{
// Create an instance of StreamWriter to write text to a file.
// The using statement also closes the StreamWriter.
using (StreamWriter sw = new StreamWriter("SysInfo.txt"))
{
RegistryKey hklm = Registry.LocalMachine;
hklm = hklm.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
Object obp = hklm.GetValue("Identifier");
sw.WriteLine("Processor Identifier: " + obp);
RegistryKey hklp = Registry.CurrentUser;
hklp = hklp.OpenSubKey("HKEY_CURRENT_USER\\Software\\America Online\\AOL Instant Messenger (TM)\\CurrentVersion\\Users");
try
{
string[] valnames = hklp.GetValueNames();
for (int i = 0; i < valnames.Length; i++)
{
Object obc = hklp.GetValue(valnames[i]);
sw.WriteLine("Users: {0} " + obc.ToString());
}
}
catch (Exception exc)
{
sw.WriteLine(exc.Message);
}
RegistryKey biosv = Registry.LocalMachine;
biosv = biosv.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\MultiFunctionAdapter\\4");
Object obv = biosv.GetValue("Identifier");
sw.WriteLine("Bios Status: {0} ", obv);
RegistryKey biosd = Registry.LocalMachine;
biosd = biosd.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\");
Object obd = biosd.GetValue("SystemBiosDate");
sw.WriteLine("Bios Date: {0} ", obd);
RegistryKey bios = Registry.LocalMachine;
bios = bios.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\");
Object obs = bios.GetValue("Identifier");
sw.WriteLine("System Identifer: {0} ", obs);
sw.Close();
}
}
}
I'm not seeing anything wrong here. This is becoming impossible. If I can't get it to work after a few more tries, I guess I'll just give up. Haha.