I've finally gotten this thing to open information and place it into a text file.
My next question is, how do I get this part to work? I've bolded the registry key that I'm trying to put into the notepad file, but this one just will not work. What am I doing wrong?

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);

         [b]RegistryKey hklp = Registry.HKEY_CURRENT_USER;
            hklp = hklp.OpenSubKey("HKEY_CURRENT_USER\Software\America Online\AOL Instant Messenger (TM)\CurrentVersion\Users");
            Object obc = hklp.GetValue("Users");
            sw.WriteLine("Users: {0} ", obc);[/b]

            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();

        }
    }
}

Basically I want it to place all those users on my computer into the file.

Whats the problem? you didnt say if there was an error.

What is the value in the registry? Is it a delimited text?

I think I'm using the wrong information to grab the key from the registry.
All it does it underline this part: HKEY_CURRENT_USER\Software\America Online\AOL Instant Messenger (TM)\CurrentVersion\Users in red and gives me this message: "Unrecognized escape sequence."

Thats because you made a mistake. In C# a \ is an escape sequence (used for special characters such as carriage return \r or new line \n). So a \ in a string is also a special character and so needs the escape sequence ie \\. As you see in your other reg strings (you left it out in this one).
The other way round it if you are not using special characters in your string is to use the @ symbol in front of the quotes which tells c# to take the string literally (beware if you use this then \r will appear as \r not a carriage return.

So your choices are hklp = hklp.OpenSubKey(@"HKEY_CURRENT_USER\Software\America Online\AOL Instant Messenger (TM)\CurrentVersion\Users"); or hklp = hklp.OpenSubKey("HKEY_CURRENT_USER\\Software\\America Online\\AOL Instant Messenger (TM)\\CurrentVersion\\Users"); both will work :)

hope it helps

Alright then. So now I have changed that part to

RegistryKey hklp = Registry.CurrentUser;
            hklp = hklp.OpenSubKey("HKEY_CURRENT_USER\\Software\\America Online\\AOL Instant Messenger (TM)\\CurrentVersion\\Users");
try
{
	Object obc = hklp.GetValue("Identifier");
	sw.WriteLine("Users: {0} " + obc.ToString());
}
catch (Exception exc)
{
	sw.WriteLine(exc.Message);
}

Now when the program runs, it creates the file and everything, but in the part where it's supposed to have the AIM sign ons, it says "Object reference not set to an instance of an object."

Blah...this is frustrating. And I know I'm using the correct registry key path.

but you went and changed the key now.
it used to be
Object obc = hklp.GetValue("Users");
and now you just posted
Object obc = hklp.GetValue("Identifier");

be careful when you code you make mistakes if not paying attention. If it is frustrating then walk away for 30 minutes - you will come back refreshed.

Anyway, put the proper key in from your registry and it will work

Done, but it's still not working.
Apparently there's no way to get it to do that.
Oh well.

if you can see it in reg edit then it can be done in C#.
The trouble is i am working blind here as cannot see your registry etc and dont have AIM myself.
Can you tell me what the value is in your registry that you are trying to display? I dont need the names of your contacts, just whether it is a dword and a sample of the content (eg comma delimited string, or semi colon or what. Then i can help more

ok that helps a lot :)

you need this bit of code

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.count; i++)
     {
	Object obc = hklp.GetValue(valnames[i]);
	sw.WriteLine("Users: {0} " + obc.ToString());
     }
}
catch (Exception exc)
{
	sw.WriteLine(exc.Message);
}

See if that helps

for (int i = 0; i < valnames.count; i++)

'System.Array' does not contain a definition for 'count'

c# is case sensitive... i thought you wouldnt just blindly copy n paste.
valnames.Length

Yeahh... sorry, I should have noticed that myself.
I've been working on this too much today. Sorry.

lol dont worry.. will teach us both to pay more attention.
Like i said before... take a break and come back to it.. sometimes you cant see the wood for the trees or just keep following the wrong path over and over.

It should work now. The GetValueNames() should return a string array with all the names in the key (not the data you highlighted in pink but the corresponding Name column) then we went through each of those in turn and called the GetValue passing in the name one at a time... this will then return your highlighted data one at a time.
Follow it?

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.

not paying attention again!!! lol
hklp = hklp.OpenSubKey("HKEY_CURRENT_USER\\Software\\America Online\\AOL Instant Messenger (TM)\\CurrentVersion\\Users");

is wrong. hklp already equals HKEY_CURRENT_USER so you are asking to find a subkey the same name... try
hklp = hklp.OpenSubKey("Software\\America Online\\AOL Instant Messenger (TM)\\CurrentVersion\\Users");

Aw crap, I thought I'd changed that.
Oh well, I took a well-needed break and helped my cousin install an ethernet card...haha, so hopefully now I can sit here and try this again.

Ahh! It works!
Thank you SO much for your patience...haha. :)

I do have one more question though. I've sent this program via a link to a friend and he claims it doesn't work. He gets an error message or something. Could this be because he doesn't have the .NET framework on his computer?

The link is http://www.classic-chick.net/Aimproject.exe

for some reason the posted message didnt show up.
It is probably because he doesnt have the framework on his pc. Just go to MS Downloads and download dotnetfx.exe for .net 2 (that way he can run 1.1 and 2.0 apps with no problem). Make sure it is the dotnetfx.exe which it the runtime not the sdk or he will be downloading all day!

Is there any way to make a C# program work on a computer WITHOUT .NET framework 2.0?

no. every program needs its framework, whether it is java or anything else.
Why? Problems?

well c# can work with 1.1 if you built it with 1.1. something built on 1.1 will run on .net 1.1 or 2.0 but something built with .net2 will only work on 2.0 runtime

This article has been dead for over six months. Start a new discussion instead.