Nov 16th, 2011, 08:19 PM
VB6 - Get HD Serial w/o WMI
This is the HDSLN class. Its purpose is to retrieve the actual serial number of the first hard drive without using WMI, an unreliable service for application use.
It should be usable in VB5 as well as VB6 but has not been tested there yet. It should be usable on Win9X systems but has not been tested there yet.
See the comments in HDSLN.cls, in some scenarios it may fail to retrieve the base hard drive serial number unless run elevated.
First it tries to grab the "Genuine Advantage" value from the registry, which probably only applies to legal activated copies of recent Windows versions. If not available, it attempts to retrieve the serial number of PhysicalDrive0 which is usually an IDE boot drive. On Windows after XP this requires elevation!
If it cannot retrieve the serial number an empty string ("") is returned.
It is presented here wrapped in a tiny demo project that just displays the result via MsgBox. See the comments for more information on its use.
I don't have a Win9X system set up, so testing there by somebody else would be useful.
Last edited by dilettante; Nov 16th, 2011 at 08:29 PM.
Click Here to Expand Forum to Full Width