Solved

Hard Disk Serial Number

Posted on 1998-11-26
2
538 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

733 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