| | |
Help with another key. (Almost done)!
Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Mar 2006
Posts: 16
Reputation:
Solved Threads: 0
C# Syntax (Toggle Plain Text)
for (int i = 0; i < valnames.count; i++)
'System.Array' does not contain a definition for 'count'
•
•
Join Date: Jan 2006
Posts: 275
Reputation:
Solved Threads: 11
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?
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?
•
•
Join Date: Mar 2006
Posts: 16
Reputation:
Solved Threads: 0
The same thing is still happening. (The object reference not set to an instance of an object).
Here's the entire program once again:
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.
Here's the entire program once again:
C# Syntax (Toggle Plain Text)
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(); } } }
•
•
Join Date: Jan 2006
Posts: 275
Reputation:
Solved Threads: 11
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");
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");
•
•
Join Date: Mar 2006
Posts: 16
Reputation:
Solved Threads: 0
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
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
![]() |
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
Views: 5605 | Replies: 24
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast button c# chat check checkbox class client code color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption event excel file files form format forms ftp function gcd gdi+ http httpwebrequest image index input install java label list listbox listener login math mouseclick mysql networking object operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource saving serialization server sleep socket sql statistics stream string tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





