| | |
Help with another key. (Almost done)!
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2006
Posts: 16
Reputation:
Solved Threads: 0
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?
Basically I want it to place all those users on my computer into the 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);
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);
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.
•
•
Join Date: Jan 2006
Posts: 275
Reputation:
Solved Threads: 11
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
or
both will work
hope it helps
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
•
•
Join Date: Mar 2006
Posts: 16
Reputation:
Solved Threads: 0
Alright then. So now I have changed that part to
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.
C# Syntax (Toggle Plain Text)
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.
•
•
Join Date: Jan 2006
Posts: 275
Reputation:
Solved Threads: 11
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
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
•
•
Join Date: Jan 2006
Posts: 275
Reputation:
Solved Threads: 11
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
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
•
•
Join Date: Mar 2006
Posts: 16
Reputation:
Solved Threads: 0
I made a screenshot for you...hopefully that will help you to see what I'm talking about.
I outlined the information I want in pink.
http://www.classic-chick.net/registry.jpg
I outlined the information I want in pink.
http://www.classic-chick.net/registry.jpg
•
•
Join Date: Jan 2006
Posts: 275
Reputation:
Solved Threads: 11
ok that helps a lot 
you need this bit of code
See if that helps

you need this bit of code
C# Syntax (Toggle Plain Text)
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
![]() |
Similar Threads
- Apostrophe - How to find the key location. (Windows 95 / 98 / Me)
- Keyboard Issue: New IE window opens when using the "L" key. (Viruses, Spyware and other Nasties)
- deleting registry key for error code 19 (Windows NT / 2000 / XP)
- Don't Ignore the Windows Logo Key (Windows tips 'n' tweaks)
Other Threads in the C# Forum
- Previous Thread: i need help...syntax error
- Next Thread: Custom Control Button with different regions
| Thread Tools | Search this Thread |
.net access algorithm alignment app array barchart bitmap box broadcast c# c#gridviewcolumn cast check checkbox client combobox communication control conversion csharp custom database datagrid datagridview dataset datatable datetime degrees development draganddrop drawing elevated encryption enum excel file focus form format forms function gdi+ hospitalmanagementsystem httpwebrequest image index input install java label list listbox localization login mandelbrot math messagebox mouseclick mysql operator path photoshop picturebox pixelinversion plotting pointer post programming radians read regex remote remoting richtextbox server sleep socket sql statistics stream string stringformatting sun table text textbox thread time timer update usercontrol validation visualstudio webbrowser whileloop windows winforms wpf xml





