Gathering computer information using WMI

After a ton of questions regarding the the DriveInfo examples (Determine Hard Drive Serial Numbers and Revenge of DriveInfo) asking how to determine other information such as CPU identification, motherboard serial number and BIOS serial numbers I’m updated the WMI version of the application to read this information. Why the WMI version? Well as it turns out, it appears that aren’t Win32 methods to pull the CPU identification information. The only examples I could find where using assembler, which is kind of tough (read, impossible) using .NET code. I wouldn’t be too difficult to create a reusable Win32 style library to get this information, but it would be another file to package with your product and WMI is there ready to be used. Because of this, my choice was to update the WMI version for gathering this type of information since it probably wouldn’t be happening very often. However…

I still think you should investigate using the Revenge of DriveInfo example for gathering drive information. The WMI version on my newest machine yielded no serial number for the primary (only) drive and, sure enough, my P/Invoke version read it just fine. So mix and match as you see fit… enjoy!


This post is licensed under CC BY 4.0 by the author.