• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 806
  • Last Modified:

serial number in BIOS?

We are looking for way to identify PC hardware programatically.  We considered using the ethernet address coded into the card, but we sometimes change out network cards.  DOS environment variables are not secure enough.

My boss says that the newer BIOS chips have a serial number in them that is unique.   I am looking for a way to retrieve the serial number that is flexible enough to handle different BIOS suppliers (AMI, Phoenix) and will handle new BIOS revisions.  If there is indeed a serial number coded into the BIOS, I'm sure it moves around every time the code is assembled.
1 Solution
It's not safe getting the BIOS serial number. It's better to obtain the hard disk serial number of a DOS drive

Here you have the code:

 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h>
 #include <dos.h>

struct info {
    int  info;             //  DW 0         Info Level
    long serial_num;       //  DD ?         Volume Serial Number
    char label[11];        //  DB 11 Dup(?) Volume Label
    char file_sys[8];      //  DB  8 Dup(?) File System Name

int main(int argc, char* argv[])
   union {
      unsigned long sn;
      unsigned int words[2];
   } sn;

   struct SREGS sregs;
   union  REGS  regs;
   struct info  buff;

   int  drive = 0, error;

   if(argc == 2)
      drive = tolower( argv[1][0] ) - 'a' + 1;

   regs.x.dx = FP_OFF(&buff);
   sregs.ds  = FP_SEG(&buff);
   regs.h.bl = drive;          // BL contains the drive. 0=current, 1=A,
   regs.x.ax = 0x6900;

   error = intdosx( &regs, &regs, &sregs );
   if( regs.x.cflag )
      fprintf(stderr, "DOS Error: Disk Drive type %d\n", error);
      return 1;

   sn.sn = buff.serial_num;
   printf("Disk serial number: %04X-%04X\n", sn.words[1], sn.words[0]);

   return 0;

// get volume label name

#include <stdio.h>
#include <dir.h>
#include <dos.h>

   ffblk ffblk;  //DOS file control block structure used to get label name
   findfirst ("c:\\*.*", &ffblk, FA_LABEL);
   printf("\n%s\n", ffblk.ff_name);
   return 0;

Hope this help
If you  use HD serial numbers you'll get into trouble when you upgrade to a bigger disk...
Whatever hardware info you use, you'll always get into trouble when you upgrade part of your system.

You can get ID of CPU. This is only additional information, but
it's good enough with information about BIOS. If you need it,
send me E-mail and I explain it in details.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

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