Solved

Getting BIOS-serial ?

Posted on 1998-06-03
6
566 Views
Last Modified: 2011-03-07
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
Comment
Question by:Erik N
  • 3
  • 2
6 Comments
 
LVL 1

Accepted Solution

by:
Edo082297 earned 200 total points
ID: 1350036
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
 
LVL 6

Expert Comment

by:Holger101497
ID: 1350037
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
 
LVL 1

Expert Comment

by:Edo082297
ID: 1350038
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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 6

Expert Comment

by:Holger101497
ID: 1350039
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
 

Author Comment

by:Erik N
ID: 1350040
Thank you Edo !
/Erik N
0
 
LVL 6

Expert Comment

by:Holger101497
ID: 1350041
Any way to do it in Windows 95 with Delphi 3.0?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question