How to Read the Drive’s Serial Number

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;

Tags: , , , , ,

No Comments Yet

You can be the first to comment!

Leave a comment

OpenID Login

Standard Login