Archive

Archive for the ‘Hardware’ Category

How to Read the Drive’s Serial Number

December 15th, 1999 m3Rlin No 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;

How to Read the Mainboard’s BIOS Information

December 15th, 1999 m3Rlin 2 comments

Mainboard BIOS information can be very useful. Let’s say, for instance, that you want to make sure nobody makes illegal copies of your program. The most popular way is to use a serial number. But serial numbers can be copied or even published on the Internet. The only way to get over this is to make a unique serial number for every computer. But how? Well, how about using the mainboard’s BIOS serial number or date? :-) To make the serial number even harder to crack you may also use the system version or build number. To do so use the Windows API GetVersionEx() function. Now all you need is some kind of encrypting algorithm to create a serial number. Just add the user’s name and company and you have what you want :-)

Note: This code may not work on certain computer systems. Certain manufactors have their own BIOSes and therefor not always follow standards. Also this code is highly unlikely to work on Windows NT and it’s succesors. This is because NT is very restrictive of hardware access.

OK, but this tip is not about serial numbers ;-) So, if you want the mainboard BIOS information you have to read to from the memory. Here’s the code:

  var
    sMainBoardBiosCopyright,
    sMainBoardBiosDate,
    sMainBoardBiosName,
    sMainBoardBiosSerialNo: string;
  ...
  try
    sMainBoardBiosName := string(PChar(Ptr($FE061))); // Bios name
    sMainBoardBiosCopyright := string(PChar(Ptr($FE091))); // Bios copyright
    sMainBoardBiosDate := string(PChar(Ptr($FFFF5))); // Bios date
    sMainBoardBiosSerialNo := string(PChar(Ptr($FEC71)));  // Bios serial number
  except
    sMainBoardBiosName := 'Unsupported';
    sMainBoardBiosCopyright := 'Unsupported';
    sMainBoardBiosDate := 'Unsupported';
    sMainBoardBiosSerialNo := 'Unsupported';
  end;