[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 588
  • Last Modified:

Getting BIOS-serial ?

Is it possible to get the computers BIOS-serialnumber by using Delphi ? How do I do it?

I run Delphi Developer 2.0...

Thanx!
/ Erik N
0
Erik N
Asked:
Erik N
  • 3
  • 2
1 Solution
 
Edo082297Commented:
Here, try this:

unit GetBIOS;
interface

uses WINPROCS;

function GetBiosSerial: LongInt;

implementation

function allocRealModePointer(var P: pointer; Size: longInt): boolean; forward;
function freeRealModePointer(var p: pointer): boolean; forward;

function GetBiosSerial: LongInt;
{ code Test: The Rom-Bios' date is allways at $ffff:0005 (real-mode)}
var
  l: ^LongInt;
begin
  l := Ptr($FFFF, $0005); {FFFF5 -> data da Rom-Bios}
  if AllocRealModePointer(Pointer(l), 8) then {8 chars to RomBios' date}
  begin { Use p to read ROM Bios' date here}
    GetBiosSerial := l^;
    FreeRealModePointer(Pointer(l)); {dispose l}
  end;
end;

function allocRealModePointer(var P: pointer; Size: longInt): boolean;
var
  Selector, base : word;
  LinearBase : longint;
begin
  result := false;
  LinearBase := MakeLong(0,hiword(longint(p)) shr 12) + hiword(longint(P)) shl 4 +           loword(longint(P)); {converts 20-bit address into a 32-bit one} {i.e. $ffff:0006 into $000ffff6}        Selector := AllocSelector(DSeg); {Copies DSeg Selector properties }
  base := SetSelectorBase(Selector, LinearBase);
  SetSelectorLimit(Selector, Size);
  if (Selector <> 0) and (base<>0) then
  begin
    P := Ptr(Selector, 0);
    result := true;
  end;
end;

function freeRealModePointer(var p: pointer): boolean;
var
  fr : Word;
begin
  fr := FreeSelector(hiword(longint(p))); {seletor is at hiword(p)}
  if (fr=0) then
  begin {ok}
    p := nil;
    result := true;
  end
  else
  begin {fail}
    result := false;
  end;
end;

{Author: Jose Bastos Neto}

HTH

Edo
0
 
Holger101497Commented:
Really cool! I haven't tried it yet, but this looks like something I was looking for as well...

Specifically, I was looking for a "unique System ID" that I can use to copy-protect my programs that are distributed to a very limited number of people (<20).

How likely is it to have two computers with the same BIOS serial no? Is this just a version number that will be the same in systems with the same motherboard/BIOS? Or is it almost unique?

Which other information from the computer could I use to get a unique ID? BIOS sounds good because it's rarely replaced... in times of huge harddisks that are replaced or repartitioned every once in a while, that's not a good indicator...

btw: Does anybody know how to get the serial-number of hard disks? I had some code to do it in DOS, but it doesn't work in windows (was some inline assembler! (read the boot sector))

Thanks!

P.S.: Erik, I would appreciate it if you waited a day or so with accepting the answer so I'll have time to read any additional comments... Thx!
0
 
Edo082297Commented:
Hi Holger,
  I STAND TO BE CORRECTED:
  The BIOS serial is supposed to be unique. This, in conjunction with a username, gives you a very good chance of having a unique identifier for a given system. Hard disks may be replaced, but unless the motherboard is replaced, the same BIOS serial will remain (this information is stored in EEPROM in the cpu itself). People always want to do stuff like this. The problem is that when the user changes systems (and they will!), they will call you and whine. Users don't like this.
  MY RAMBLINGS:
  Someone needs to write a program that would use a call back modem (or some other such guaranteed identification process) to distribute a key to unlock a given software product. The user would be registered, and your software would automatically dial in, pass in a password of sorts, and get the new key, allowing the program to continue  functioning properly.
  If someone tried to fool the system, then all would go ok for a couple of days, before your program would format their hard drive (event: OnPiratedCopyFound) :)

Edo
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Holger101497Commented:
HELP!
I tried ypur code, but it won't work in 32-bit Delphi (i.e. Win 95/NT, which by now probably is much more common than Win3.1 *g*)
I feel a bit insecure messing with code I don't really understand. Well, I understand what it does, but I don't know if it still does the same thing if i change it...

The problems are at least these:
1) l := Ptr($FFFF, $0005); => Segment/Offset pairs not supported.
I forgot how to convert manually... wasn't it 16 bytes to a segment? So would it have to be I:=Ptr($FFFF5)?

2) AllocSelector: The AllocSelector function is not implemented in the Win32 API. Win32-based applications should use the VirtualLock and VirtualUnlock functions.
Well, the help says that VirtualLock makes sure the page is not paged out... How can the BIOS be paged out to the swap-file? It also says that this function doesn't do anything in Win 95

3) SetSelectorBase: Not known at all...

Of course I'm not normally allowed to read address 000FFFF5 and trying to do so causes an access violation.

I'd appreciate any help, because this is important! Thanks!!
0
 
Erik NAuthor Commented:
Thank you Edo !
/Erik N
0
 
Holger101497Commented:
Any way to do it in Windows 95 with Delphi 3.0?
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now