Home > Hardware > How to Read the Drive’s Serial Number

How to Read the Drive’s Serial Number

December 15th, 1999 m3Rlin Leave a comment Go to comments

The drive’s serial number can be useful for for a lot of things (check out previous tip). This example code shows you how to read the hard drives serial number.

function GetHddSerial: Integer;
var
  aBuffer: array [0..255] of Char;
  dwTemp: DWord;
  pdwSerial: PDWord;
begin
  if GetVolumeInformation('c:', aBuffer, SizeOf(aBuffer), @pdwSerial, dwTemp, dwTemp, nil, 0) then
    Result := pdwSerial^;
end;
  1. No comments yet.