Computing.Net > Forums > Programming > Retrieving system info in C#??

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Retrieving system info in C#??

Reply to Message Icon

Name: El-Trucha
Date: March 24, 2005 at 16:14:12 Pacific
OS: Windows XP SP2
CPU/Ram: 2.8 GHz/448 MB
Comment:

OK...I'm following instructions here:
http://www.codeproject.com/csharp/Hardware_Properties_C_.asp
That works, like this:


ManagementObjectSearcher searcher =
new ManagementObjectSearcher("Select Name from Win32_CDROMDrive");
foreach(ManagementObject cdrom in searcher.Get())
{
message += "CD-ROM: " + cdrom.GetPropertyValue("Name").ToString() + "\n";
}

But it doesn't work if I want to get info from the motherboard:


searcher = new ManagementObjectSearcher("Select Name from Win32_BaseBoard");
foreach(ManagementObject mobo in searcher.Get())
{
message += "Motherboard Maker: " + mobo.GetPropertyValue("Manufacturer").ToString() + "\n";
}

I get an exception... :(
What am I doing wrong??
Thanx!! ;)

El-Trucha
http://www.truchasoft.tk
ftp://tsfc.homeftp.net
hotline://tsfc.ath.cx



Sponsored Link
Ads by Google

Response Number 1
Name: SN
Date: March 24, 2005 at 18:54:58 Pacific
Reply:

The exception is telling you that there were no results returned, so having the result in a foreach loop like that is no good. It would be better to check the count of the results first, then go into the foreach.

Anyhow, if you look in the MSDN documentation for these WMI hardware classes, you'll see that Win32_CDROM is available Windows XP, while Win32_BaseBoard is only available on Server 2003, Server 2000, or NT 4.0. The "server" requirements are the ones that apply to your situation.

WMI Computer system hardware classes

Good luck,
-SN


0

Response Number 2
Name: El-Trucha
Date: March 25, 2005 at 17:32:37 Pacific
Reply:

Oooooooooohhhhhhh.......I get it now!! :D
Thanx!! ;)

(and sorry for not answering - as I told u on my other post, it didnt show up on the My Computing.Net page...) :(

El-Trucha
http://www.truchasoft.tk
ftp://tsfc.homeftp.net
hotline://tsfc.ath.cx


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Retrieving system info in C#??

Retrieving Computer info in C www.computing.net/answers/programming/retrieving-computer-info-in-c-/5193.html

System-pause - in c#? www.computing.net/answers/programming/systempause-in-c/10626.html

Display a system call in C++ www.computing.net/answers/programming/display-a-system-call-in-c/10868.html