How to retrieve hardware serial numbers under Windows?

Started by
8 comments, last by Ramius 18 years, 2 months ago
Anyone know how to retrieve the serial number of a hardware device, preferably the hard disk drive, under Win 98 and later? I've searched the net in vain for a method that works under Windows 9x/2000 (Win XP has the WMI classes). And yes, it's for a simple copy protection scheme. :)
- Daniel Roth, Programmer / Web Developer (www.starquail.com, www.cwu.edu)
Advertisement
If you use the GetVolumeInformation function you can get the serial number for a volume (ie C:\). This is not a hardware serial number so it will change if the disk is reformatted. I looked into this a while ago and I couldn't find the hardware serial number, so if you do i'd be interested to know the method as well ;)
"Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan
Yeah, there's like a dozen documented ways for retrieving the volume serial number but none for the actual manufacturer serial number. [rolleyes] I wouldn't have any problem with binding an install to the volume number if it wasn't so easy for the end user to change said number. While I imagine even a "hard" serial number could be faked by an extreme power user (could use a RAMdisk or custom device driver or something) I would think that it would stop the majority of people. On the other hand, your casual user probably doesn't even know what a volume serial number is, so I guess it could do well enough for my purposes. Still would like to know how to access the manufacturer's serial though. [smile]
- Daniel Roth, Programmer / Web Developer (www.starquail.com, www.cwu.edu)
You'd have to investigate the functions CreateFile and DeviceIoControl.

look at this example:

http://www.dotnetspider.com/Question6159.aspx

I hope that helps.
You could use the MAC address of the network card instead. Probably less intrusive, although not everyone is on hi-speed LANs.
You could use the MAC address of the network card instead. Probably less intrusive, although not everyone is on hi-speed LANs.
Quote:You'd have to investigate the functions CreateFile and DeviceIoControl.


Thanks for the tip. Unfortunately, DeviceIoControl can only access the old DOS int 21h functions when called under Win 9x, and to the best of my knowledge none of those can query for a physical drive's hardware serial number.

Quote:You could use the MAC address of the network card instead.


I thought about using the serial number (or other semi-unique identifier like a MAC address) of some piece of hardware other than the hard disk, but I'd like my copy protection scheme to be as convenient to the end user as possible. This makes a hard disk the ideal physical object to bind my program to, as it's generally the least likely thing to be replaced during a system upgrade. That's also the reason why I'd prefer to use the hardware serial # vs the volume #, as the former doesn't get changed during a reformat. :)
- Daniel Roth, Programmer / Web Developer (www.starquail.com, www.cwu.edu)
Quote:Original post by Anonymous Poster
You could use the MAC address of the network card instead. Probably less intrusive, although not everyone is on hi-speed LANs.


unfortunately you can hide your mac address by software which is actually quite common to avoid punkbuster detection

on linux you can get all this information quite easy with some console commands
*please don t ask me for the command names. its a while back that i needed them*
http://www.8ung.at/basiror/theironcross.html
Take a look at this site. Not completely sure it will give you what you are looking for, but it certainly looks possible. Source code and all.

http://www.winsim.com/diskid32/diskid32.html
Quote:http://www.winsim.com/diskid32/diskid32.html


Thank you very much for that link. :) It's the first documentation I've seen that covers methods for Win 9x, 2k, and XP. Unfortunately, having looked through the code provided I've decided that its limitations (no SCSI support, requiring direct port manipulations under 9x, etc.) are too risky to base a no-hassle copy protection scheme around. So I guess it's back to using the volume serial # for me. [cool]
- Daniel Roth, Programmer / Web Developer (www.starquail.com, www.cwu.edu)

This topic is closed to new replies.

Advertisement