Am trying to get the manufacturer serial number (not volume number) of usb external harddrives or disk?
[EDIT] i don't know or have any code yet on how to do this. the previous method i tried only returned the volume serial number
Am trying to get the manufacturer serial number (not volume number) of usb external harddrives or disk?
[EDIT] i don't know or have any code yet on how to do this. the previous method i tried only returned the volume serial number
You can use WMI to retrieve this information. Hard drive serial numbers are in
Win32_PhysicalMedia
. I'm not going to take the time to write the code here; if you have any experience querying WMI in VB 6, you should be able to do it without much trouble. Otherwise, search for sample code online. You won't find much of anything specifically about hard drive serial numbers, but you'll find lots of WMI examples.Be weary of the fact that you won't always get the serial number in the format you're expecting. For example, comments to this article indicate you might get something like:
in which case, you will have to decode the serial number:
I'm also not positive that all external/removable hard drives provide this information. Your mileage may vary, but the suggested method does work fine on internal hard drives.
Alternatively, it appears that you can do this using low-level Windows APIs like
DeviceIOControl
. You'll need to add declarations for the necessary functions to a module in your VB 6 app. This article on Code Project should help get you started; the code is written in native C++ and it's geared for consumption by .NET languages like C#, but I see no difficulty in adapting the code to VB 6.