If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: How can i get the Serial number of Hard Disk.

That MIGHT be just volume serial number...I don't know my Manufacturer's serial number for the (actual) hard disk, but when I run that, I get "A" serial number (obviously for 'C-Drive'). SO, not sure if that is what you are looking for or not.

to hunt a species to extinction is not logical !since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

Re: How can i get the Serial number of Hard Disk.

???

I am lost as to what you want now

regards
Chris

to hunt a species to extinction is not logical !since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

Re: How can i get the Serial number of Hard Disk.

Hi ChrisE,

I want to get the manufacturers serial number of Hard Disk. Not the Partition volume serial Number. The code in the link at #6 may work. But as it is not returning any value i think the problem is with 64 bit. As i am using 64bit OS. The code was written for 32bit (if i am right).

so my question is how to get "manufacturers serial number of Hard Disk. Not the Partition volume serial Number."

to hunt a species to extinction is not logical !since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

Re: How can i get the Serial number of Hard Disk.

Thank you. It solved my problem. One clarification please. The output in "SerialNo" will get changed after formatting or remain unchanged.

well you will have to try it out. The sample in Post #4 will read a new "SerialNo" after formatting.

regards
Chris

to hunt a species to extinction is not logical !since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

Re: How can i get the Serial number of Hard Disk.

And I think it might depend on what you mean by "formatting".

A "format" from Windows doesn't really do much of anything. It just deletes the root directory structure and builds a new/empty one. For a FAT system, I could tell you precisely what it does. However, I'm not totally familiar with that low-level stuff on NTFS systems.

However, a "true format" will completely ignore everything on a hard-disk, and rebuild all the sectors from scratch. This isn't typically done with canned Windows utilities, but typically with a utility from the hard-disk's manufacturer.

So, I would think that a Windows format may leave the serial number intact, where a low-level format would, almost by necessity, probably overwrite it (but it might try to read it and replace it once reformatted, but that may also depend on the manufacturer and the format utility used).

Best Regards,
Elroy

EDIT1: Also, it may depend on how the serial number is stored. If it's stored in some ROM chip on the hard-disk's controller board, then no formatting of any kind should tamper with it. I don't know if there are standards for this or not. If not, I suspect different hard-disk manufacturers may do it differently.

Last edited by Elroy; Oct 1st, 2017 at 01:44 PM.

Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

Re: How can i get the Serial number of Hard Disk.

WMI is not something you want to rely upon. It is a hazardous tool meant only for administrator usage, so the service might not be present at all, might be stopped, or might be secured against non-admin use.

It also has another problem... before Windows 8 it reports drive serial numbers incorrectly:

Now that I know about the "correction" in Windows 8 and beyond I have altered that code to work properly. I have tested it on Windows 10, and now on Windows Home Server 2011 (basically Windows 7/Windows Server 2008 R2).

The attachment contains a small demo project that enumerates all drives.

The DriveInfo class accepts a drive letter assignment to its Letter property. This causes it to look up drive information. After that you can interrogate several other properties such as the SerialNumber property.

Re: Tracing HDD Serial Number

Annoying, hmm?

I'm not sure what path gets taken for USB HDDs so I'll try experimenting to see if that case can be corrected. You might think this would be a pretty solid thing, but the information really isn't important to Windows or most applications. Since it is normally only used for inventory purposes Microsoft probably didn't have much incentive for getting it right and making it more easily accessible.

I suppose "flipped characters" don't matter much in a copy protection scheme or something unless somebody moves from pre-Win8 to Win8-or-later. At that point letter-swapping might break any existing registration data.

Re: Tracing HDD Serial Number

Yes its absolutely true that in copy protection its useful and that i was searching for.

The version 2.1 is now tracing the External HDD S/N correctly. But now its reading HDD SerialNumber = "02020202020202020202a5027463345553434574" exactly the same as in code #9 but in a flipped manner to each 2 characters.

Re: Tracing HDD Serial Number

Ouch. That's disappointing.

You must have a drive that returns the serial number as ASCII hex digits, something I commented out as obsolete. When I left it in there I was getting garbage characters for the serial number of a USB HDD.

I'll have to play with it more to see if I can create a version that can tell the difference between a string of hex and a string that only contains hex digit characters.

This isn't easy because of the inconsistent results for different drives and buses.

to hunt a species to extinction is not logical !since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

Re: [RESOLVED] How can i get the Serial number of Hard Disk.

Here is another update that might refine the results a little more for some hard drives.

This version tries collapsing "hex digits" to ASCII, then if the resulting "ASCII" looks like a valid serial number (alphanumeric, hyphens, spaces) it keeps that. Otherwise it reports the "digits" as the serial number.

Sort of a heuristic process but as far as I can tell disk serial numbers were done in several ways over the years.

to hunt a species to extinction is not logical !since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

If I get Time next week I'll try again, and Report if I could get it solved

regards
Chris

to hunt a species to extinction is not logical !since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

Re: [RESOLVED] How can i get the Serial number of Hard Disk.

One thing you might try is this change:

Code:

Private Type STORAGE_DEVICE_DESCRIPTOR
Version As Long '0
Size As Long '4
DeviceType As Byte '8
DeviceTypeModifier As Byte '9
RemovableMedia As Byte '10
CommandQueueing As Byte '11
VendorIdOffset As Long '12
ProductIdOffset As Long '16
ProductRevisionOffset As Long '20
SerialNumberOffset As Long '24
BusType As BUS_TYPES '28
RawPropertiesLength As Long '32
RawDeviceProperties(36 To 511) As Byte '36
End Type

I.e. increasing the size of the buffer, more bytes for RawDeviceProperties. Just a wild guess though.