Solved

Hard Disk Serial Number

Posted on 1998-11-26
2
537 Views
Last Modified: 2008-02-01
Ho do I get the hard disk serial number / or volume serial number using in win3.11. In win95 it is possible to use the GetVolumeInfo() API, but not for win3.11. Is the serial number in RAM, and if so where is it. Is it possible to write some in line assembley code to do fetch it.

Thanks

Rathe
0
Comment
Question by:rh113
2 Comments
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 100 total points
ID: 1178678
It is you code in C++(not Assembler):
void FindDiskName(char *szNameDisk)
{
  struct SREGS sregs;
  union  REGS regs;
  char   szTemp[512];
  int    block[5];
                              //clear all
  memset(&sregs , 0, sizeof(sregs));
  memset(&regs , 0, sizeof(regs));
  memset(szTemp , 0, sizeof(szTemp));
  memset(block, 0, sizeof(block));

  memset(szNameDisk, 0, sizeof(szNameDisk));

  block[2] = 1;
  block[3] =  FP_OFF(szTemp);
  block[4] =  FP_SEG(szTemp);

  sregs.ds = FP_SEG(block);
  regs.x.bx = FP_OFF(block);
//                     absread(as Interruption, vers 4.0 and //more)
  regs.h.al = 0x02;                  //disk C
  regs.x.cx = -1;                  //data in block
  regs.x.dx = 0;                  //1-st Sector

  int86x(0x25, &regs, &regs, &sregs);      //read
  if (regs.h.ah == 0)                  //ok?
    {
      for (int i = 42, j=0; j < 4; i--, j++)
      CtoStr(*(szTemp+i), szNameDisk + 2*j);
      szNameDisk[8] = '-';                  //form name
    }
}
static char *szDigit = "0123456789ABCDEF";
void CtoStr(char c , char *str)
{
   str[0] = szDigit [ (c>>4) & 0x0F];
   str[1] = szDigit[(c&0x0F)];
}
Regards, Alex
0
 

Author Comment

by:rh113
ID: 1178679
Thankyou Alex for your help, I guess this code will work for all platforms as well. e.i. win3.11, win95, winNT..

Thanks

Rathe
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

825 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