Board index » delphi » Hard Drive Serial Number

Hard Drive Serial Number

Anyone have any clue how to get the PHYSICAL (not volume) serial number from a drive?

I have been looking for days now and the only thing I could find was some largely uncommented assembly code from 1995.
If anyone knows of a way or a resource you can point me to, it would be very much appreciated.

Thanks,

Ryan

 

Re:Hard Drive Serial Number


See if you can find the documentation for the S.M.A.R.T. standard, all
drives support it these days. I think that's your best bet.

I suppose this is intended as a sort of copy protection scheme? Keep in mind
that WinNT won't give you direct access to the hardware unless you write a
device driver.

Quote
> Anyone have any clue how to get the PHYSICAL (not volume)
> serial number from a drive?

Re:Hard Drive Serial Number


Yes, it will be used as a protection scheme.

I know NT will not allow me access to the hardware without a driver, but I had an idea for NT machines. =)

Thanks for your help!

Ryan

Quote
On Wed, 11 Apr 2001 18:49:40 +0200, "B. Garvelink" <deg...@removethis.myrealbox.com.removethis> wrote:
>See if you can find the documentation for the S.M.A.R.T. standard, all
>drives support it these days. I think that's your best bet.

>I suppose this is intended as a sort of copy protection scheme? Keep in mind
>that WinNT won't give you direct access to the hardware unless you write a
>device driver.

Re:Hard Drive Serial Number


Here's the code I use. I fully expected it not to work under NT, but it
does.

function GetVolumeSerialNum(DriveChar: char): string;
var  OldErrorMode      : Integer;
    NotUsed, VolFlags : DWORD;
    Buf              : array [0..MAX_PATH] of Char;
    Serial            : DWORD;

begin
  OldErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS);
  try
    if GetVolumeInformation(PChar(DriveChar + ':\'),
                            Buf,sizeof(Buf), @Serial,
                            NotUsed, VolFlags,nil, 0) then
    begin

      result := AnsiUpperCase(IntToHex(serial, 8));
      result := Copy(result, 1, 4) + ':' +
                Copy(result, 5, 4);

    end
    else
      begin
      Result := 'function failed';
      end;
  finally
    SetErrorMode(OldErrorMode);
  end;
end;

--
Gary Jones <newsmas...@bohr.demon.co.uk>

Re:Hard Drive Serial Number


I think this is the volumeserial (can be changed by user), he requested the
actual hardware serial of the drive.

Quote
"Gary Jones" <newsmas...@bohr.demon.co.uk> wrote in message

news:PVHQMHAyGV16Ewot@bohr.demon.co.uk...
Quote
> Here's the code I use. I fully expected it not to work under NT, but it
> does.

> function GetVolumeSerialNum(DriveChar: char): string;
> var  OldErrorMode      : Integer;
>     NotUsed, VolFlags : DWORD;
>     Buf              : array [0..MAX_PATH] of Char;
>     Serial            : DWORD;

> begin
>   OldErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS);
>   try
>     if GetVolumeInformation(PChar(DriveChar + ':\'),
>                             Buf,sizeof(Buf), @Serial,
>                             NotUsed, VolFlags,nil, 0) then
>     begin

>       result := AnsiUpperCase(IntToHex(serial, 8));
>       result := Copy(result, 1, 4) + ':' +
>                 Copy(result, 5, 4);

>     end
>     else
>       begin
>       Result := 'function failed';
>       end;
>   finally
>     SetErrorMode(OldErrorMode);
>   end;
> end;

> --
> Gary Jones <newsmas...@bohr.demon.co.uk>

Re:Hard Drive Serial Number


In article <9b3t1c$hl...@porthos.nl.uu.net>, Ronald
<jerdek...@hotmail.com> writes

Quote
>"Gary Jones" <newsmas...@bohr.demon.co.uk> wrote in message
>news:PVHQMHAyGV16Ewot@bohr.demon.co.uk...
>> Here's the code I use. I fully expected it not to work under NT, but it
>> does.

>I think this is the volumeserial (can be changed by user), he requested the
>actual hardware serial of the drive.

Sorry about that.

I was under the impression that the volume serial number couldn't be
changed by the user. If it can, then I'd be very interested to learn
how. It might well be dead simple, I've just never come across it.

--
Gary Jones <newsmas...@bohr.demon.co.uk>

Re:Hard Drive Serial Number


On Fri, 13 Apr 2001 09:53:07 +0100, Gary Jones

Quote
<newsmas...@bohr.demon.co.uk> wrote:
>Sorry about that.

>I was under the impression that the volume serial number couldn't be
>changed by the user. If it can, then I'd be very interested to learn
>how. It might well be dead simple, I've just never come across it.

Not dead simple under Win32 but under DOS and Win16 you can do an
Absolute Disk Read and Write so you can manually alter the serial
number which lives in the first sector on the HD for MSDOS based disk
systems.

If anyone knows how to do an Int 25h and Int 26h under Delphi 32 it
would be really interesting.

Re:Hard Drive Serial Number


The message <3ad720a1.27850...@news.u-net.com>
  from  je...@iss.u-net.com (J French) contains these words:

Quote
> On Fri, 13 Apr 2001 09:53:07 +0100, Gary Jones
> <newsmas...@bohr.demon.co.uk> wrote:
> >Sorry about that.

> >I was under the impression that the volume serial number couldn't be
> >changed by the user. If it can, then I'd be very interested to learn
> >how. It might well be dead simple, I've just never come across it.

> Not dead simple under Win32 but under DOS and Win16 you can do an
> Absolute Disk Read and Write so you can manually alter the serial
> number which lives in the first sector on the HD for MSDOS based disk
> systems.
> If anyone knows how to do an Int 25h and Int 26h under Delphi 32 it
> would be really interesting.

In otherwords the average end user wouldn't have a clue how to change it.
But I guess he could always download something that will do it for him.

How would such a protection system work anyway? Would the program transmit
back to the shareware authors website, the users HDD serial?

You could stop two copies of a program being run on one machine, but what
stops the user unzipping the file onto two separate machines? Unless you
build the HDD serial into the registration code you send to the user
I can't see any other way to work it. Anybody know how to read the
processor serial number?

--
Sincerely,

Andreas Kyriacou
----------------
http://www.andrikkos.co.uk (Imagine! Image Viewer)

Re:Hard Drive Serial Number


Quote
> Anybody know how to read the
> processor serial number?

For the PIII you can go to Intel's site and download libraries
from there.   Doesn't help much if the PIII computer has had
processor ID disabled.    AFAIK, no other processor has a
serial number than can be accessed through software.

Rob

Other Threads