Mega Code Archive

 
Categories / Delphi / Hardware
 

Retrieve the volume serial number of your Hard Disk

Title: Retrieve the volume serial number of your Hard Disk. Question: How get the serial number of a hard disk. Answer: In a principle, when is begun one in the programming, seeks a method of protecting their programs of the piracy, and one of these forms is to use volume serial number of the hard drive . However I consider, after but 3-year-old of programming, that this method is the but insecure, if is used alone. In any case it is good to know at least some protection method. Not you seems? Create a function that return an String and put the following code within. var SerialNum : pdword; Buffer : array [0..255] of char; MaxCompLength, FileSystemFlags : dword; begin if GetVolumeInformation('c:\', Buffer, SizeOf(Buffer), SerialNum, MaxCompLength, FileSystemFlags, nil, 0) then Result:= IntToStr(SerialNum^); end; This routine can be generalized for any disk drive . Regards.