943,723 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 6522
  • C# RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Mar 5th, 2006
0

Re: Help with another key. (Almost done)!

C# Syntax (Toggle Plain Text)
  1. for (int i = 0; i < valnames.count; i++)

'System.Array' does not contain a definition for 'count'
Reputation Points: 10
Solved Threads: 0
Newbie Poster
EmilyBrooke is offline Offline
16 posts
since Mar 2006
Mar 5th, 2006
0

Re: Help with another key. (Almost done)!

sorry my fault not paying attention..
valnames.length
Reputation Points: 26
Solved Threads: 11
Posting Whiz in Training
f1 fan is offline Offline
275 posts
since Jan 2006
Mar 5th, 2006
0

Re: Help with another key. (Almost done)!

Well it says the same thing now, only with 'length' rather than 'count.'
:/
Reputation Points: 10
Solved Threads: 0
Newbie Poster
EmilyBrooke is offline Offline
16 posts
since Mar 2006
Mar 5th, 2006
0

Re: Help with another key. (Almost done)!

c# is case sensitive... i thought you wouldnt just blindly copy n paste.
valnames.Length
Reputation Points: 26
Solved Threads: 11
Posting Whiz in Training
f1 fan is offline Offline
275 posts
since Jan 2006
Mar 5th, 2006
0

Re: Help with another key. (Almost done)!

Yeahh... sorry, I should have noticed that myself.
I've been working on this too much today. Sorry.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
EmilyBrooke is offline Offline
16 posts
since Mar 2006
Mar 5th, 2006
0

Re: Help with another key. (Almost done)!

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?
Reputation Points: 26
Solved Threads: 11
Posting Whiz in Training
f1 fan is offline Offline
275 posts
since Jan 2006
Mar 5th, 2006
0

Re: Help with another key. (Almost done)!

The same thing is still happening. (The object reference not set to an instance of an object).

Here's the entire program once again:

C# Syntax (Toggle Plain Text)
  1. using System;
  2. using System.IO;
  3. using Microsoft.Win32;
  4. using System.Text;
  5. using System.Diagnostics;
  6. using System.Data;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9.  
  10. class Test
  11. {
  12. public static void Main()
  13. {
  14. // Create an instance of StreamWriter to write text to a file.
  15. // The using statement also closes the StreamWriter.
  16. using (StreamWriter sw = new StreamWriter("SysInfo.txt"))
  17. {
  18. RegistryKey hklm = Registry.LocalMachine;
  19. hklm = hklm.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
  20. Object obp = hklm.GetValue("Identifier");
  21. sw.WriteLine("Processor Identifier: " + obp);
  22.  
  23. RegistryKey hklp = Registry.CurrentUser;
  24. hklp = hklp.OpenSubKey("HKEY_CURRENT_USER\\Software\\America Online\\AOL Instant Messenger (TM)\\CurrentVersion\\Users");
  25. try
  26. {
  27. string[] valnames = hklp.GetValueNames();
  28. for (int i = 0; i < valnames.Length; i++)
  29. {
  30. Object obc = hklp.GetValue(valnames[i]);
  31. sw.WriteLine("Users: {0} " + obc.ToString());
  32. }
  33. }
  34. catch (Exception exc)
  35. {
  36. sw.WriteLine(exc.Message);
  37. }
  38. RegistryKey biosv = Registry.LocalMachine;
  39. biosv = biosv.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\MultiFunctionAdapter\\4");
  40. Object obv = biosv.GetValue("Identifier");
  41. sw.WriteLine("Bios Status: {0} ", obv);
  42.  
  43. RegistryKey biosd = Registry.LocalMachine;
  44. biosd = biosd.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\");
  45. Object obd = biosd.GetValue("SystemBiosDate");
  46. sw.WriteLine("Bios Date: {0} ", obd);
  47.  
  48. RegistryKey bios = Registry.LocalMachine;
  49. bios = bios.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\");
  50. Object obs = bios.GetValue("Identifier");
  51. sw.WriteLine("System Identifer: {0} ", obs);
  52. sw.Close();
  53.  
  54. }
  55. }
  56. }
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
EmilyBrooke is offline Offline
16 posts
since Mar 2006
Mar 5th, 2006
0

Re: Help with another key. (Almost done)!

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");
Reputation Points: 26
Solved Threads: 11
Posting Whiz in Training
f1 fan is offline Offline
275 posts
since Jan 2006
Mar 5th, 2006
0

Re: Help with another key. (Almost done)!

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
EmilyBrooke is offline Offline
16 posts
since Mar 2006
Mar 5th, 2006
0

Re: Help with another key. (Almost done)!

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
EmilyBrooke is offline Offline
16 posts
since Mar 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: i need help...syntax error
Next Thread in C# Forum Timeline: Custom Control Button with different regions





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC