Help with another key. (Almost done)!

Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2006
Posts: 16
Reputation: EmilyBrooke is an unknown quantity at this point 
Solved Threads: 0
EmilyBrooke EmilyBrooke is offline Offline
Newbie Poster

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

 
0
  #11
Mar 5th, 2006
  1. for (int i = 0; i < valnames.count; i++)

'System.Array' does not contain a definition for 'count'
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 275
Reputation: f1 fan is an unknown quantity at this point 
Solved Threads: 11
f1 fan f1 fan is offline Offline
Posting Whiz in Training

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

 
0
  #12
Mar 5th, 2006
sorry my fault not paying attention..
valnames.length
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 16
Reputation: EmilyBrooke is an unknown quantity at this point 
Solved Threads: 0
EmilyBrooke EmilyBrooke is offline Offline
Newbie Poster

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

 
0
  #13
Mar 5th, 2006
Well it says the same thing now, only with 'length' rather than 'count.'
:/
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 275
Reputation: f1 fan is an unknown quantity at this point 
Solved Threads: 11
f1 fan f1 fan is offline Offline
Posting Whiz in Training

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

 
0
  #14
Mar 5th, 2006
c# is case sensitive... i thought you wouldnt just blindly copy n paste.
valnames.Length
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 16
Reputation: EmilyBrooke is an unknown quantity at this point 
Solved Threads: 0
EmilyBrooke EmilyBrooke is offline Offline
Newbie Poster

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

 
0
  #15
Mar 5th, 2006
Yeahh... sorry, I should have noticed that myself.
I've been working on this too much today. Sorry.
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 275
Reputation: f1 fan is an unknown quantity at this point 
Solved Threads: 11
f1 fan f1 fan is offline Offline
Posting Whiz in Training

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

 
0
  #16
Mar 5th, 2006
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?
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 16
Reputation: EmilyBrooke is an unknown quantity at this point 
Solved Threads: 0
EmilyBrooke EmilyBrooke is offline Offline
Newbie Poster

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

 
0
  #17
Mar 5th, 2006
The same thing is still happening. (The object reference not set to an instance of an object).

Here's the entire program once again:

  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.
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 275
Reputation: f1 fan is an unknown quantity at this point 
Solved Threads: 11
f1 fan f1 fan is offline Offline
Posting Whiz in Training

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

 
0
  #18
Mar 5th, 2006
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");
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 16
Reputation: EmilyBrooke is an unknown quantity at this point 
Solved Threads: 0
EmilyBrooke EmilyBrooke is offline Offline
Newbie Poster

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

 
0
  #19
Mar 5th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 16
Reputation: EmilyBrooke is an unknown quantity at this point 
Solved Threads: 0
EmilyBrooke EmilyBrooke is offline Offline
Newbie Poster

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

 
0
  #20
Mar 5th, 2006
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum


Views: 5605 | Replies: 24
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC