Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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

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

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

![]() |
![]() |
![]() |

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