Solved

3.5 ' floppy disk serial number

Posted on 1998-01-22
6
771 Views
Last Modified: 2013-11-20
in msdos window, typing dir (for drive with 3.5 disk)
shows Label, and serial number of the disk. How can I
read these numbers programatically, and is there a way of
changing the serial number programatically ?
how unique these numbers are ?

I need definite answer, please do not guess and lock the question.
0
Comment
Question by:has
  • 3
  • 3
6 Comments
 
LVL 4

Accepted Solution

by:
tflai earned 100 total points
ID: 1314570
Look at this following page,
"Getting a drive's serial number under Windows":
http://www.borland.com/devsupport/borlandcpp/ti/TI1731.html
0
 

Author Comment

by:has
ID: 1314571
well, the hint is close but I can not compile it.
there is no GlobalDosAlloc() or anything near, (GlobalAlloc cant do the job) and MK_FP as they think in dos.h not there? so if you can
get it work, let me know. I also think that this should not be
that involved, I thing I saw a function to read the disk volume serial no,
but I am not sure. Any way  let me know if you can work it.
0
 
LVL 4

Expert Comment

by:tflai
ID: 1314572
Here's some code from Microsoft's MSDN:

 
PSS ID Number: Q69223
Article last modified on 01-24-1995
 
5.10 6.00 6.00a 6.00ax 7.00 | 1.00 1.50
 
MS-DOS                      | WINDOWS
 

----------------------------------------------------------------------
The information in this article applies to:
 
 - The C Run-time (CRT) included with:
 
    - Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, and 6.0ax
    - Microsoft C/C++ for MS-DOS, version 7.0
    - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
----------------------------------------------------------------------
 
SUMMARY
=======
 
Beginning with MS-DOS version 4.0, a semi-random 32-bit binary
identification number (ID) is assigned to each disk that MS-DOS
formats. The volume serial number (or ID) is stored at offset 27H to
2AH in the boot sector of each disk.
 
NOTE: code compiled with Visual C++ version 1.5 may yield the
following
message from Windows NT:
 
   An applicaion has attempted to directly access the hard disk, which
   cannot be supported. This may cause the application to function
   incorrectly.
 
It provides Terminate and Ignore buttons. If the user is logged on
with
Administrative privileges, this will succeed for a FAT partition, else
it
fails for a FAT partition. It always fails for an NTFS partition.
After
clicking Terminate or Ignore the program returns with the error
message
that has been coded (error on int 25).
 
MORE INFORMATION
================
 
The following program illustrates how to retrieve this information:
 
/***************************************************************/
/*                                                             */
/* This program reads the volume serial number (or ID) from    */
/* the boot sector of a specified disk. The DOS interrupt 25   */
/* Absolute Disk Read is used to read in the boot sector.      */
/*                                                             */
/* Note: The volume ID is only implemented from MS-DOS 4.0     */
/*       and later.                                            */
/*                                                             */
/* The output consists of the OEM name and version of the      */
/* disk-formatting program (stored at offset 03H to 0AH in the */
/* boot sector), the disk volume label, and the disk-volume    */
/* serial number.                                              */
/*                                                             */
/***************************************************************/
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dos.h>
#include <conio.h>
 
char bootsector[1024];
char volume[12];
char ver[9];
char block[10];
 
void main(void)
{
   int ax, _far *p, drive;
   struct find_t fileinfo;
   char filename[13], _far *myvar, _far *q;
   union REGS inregs, outregs;
   struct SREGS segregs;
 
   printf("Enter drive number (0=A,1=B,2=C, ...): ");
   drive = getche() - '0';
 
   /**************************************/
   /* Parameter block for int 25H        */
   /* Bytes    Description               */
   /* -------  -----------               */
   /* 00H-03H  32-bit sector number      */
   /* 04H-05H  Number of sectors to read */
   /* 06H-07H  Offset of buffer          */
   /* 08H-09H  Segment of buffer         */
   /**************************************/
 
   block[0] = block[1] = block[2] = block[3] = 0;
   block[4] = 1;
   block[5] = 0;
 
   myvar = bootsector;
 
   p = (int *)&block[6];
   *p = FP_OFF(myvar);
 
   p = (int *)&block[8];
   *p = FP_SEG(myvar);
 
   q = block;
   inregs.h.al = (char)drive;
   inregs.x.cx = -1;
   inregs.x.bx = FP_OFF(q);
   segregs.ds = FP_SEG(q);
   ax = int86x(0x25, &inregs, &outregs, &segregs);
 
   /*** Error routine ***/
 
   if (outregs.x.cflag)
   {
      printf("\n\nerror on int 25\n");
      printf("this is AX:%04X", ax);
      exit(-1);
   }
 
   /*** Output ***/
 
   printf("\n\nDrive %c\n-------\n\n", drive +'A');
 
   strncpy(ver, &bootsector[3], 8);
   printf("OEM name and version: %s\n", ver);
 
   /* Use _dos_findfirst for the volume label */
 
   filename[0] = (char)(drive + 'A');
   filename[1] = '\0';
   strcat(filename, ":\\*.*");
   if(!_dos_findfirst(filename, _A_VOLID, &fileinfo))
   printf("Volume name         : %s\n", fileinfo.name);
 
   /* Before printing serial number, check if version >= 4.x */
 
   if ((ver[6] == '.') && (ver[5] >= '4') && (ver[5] <= '9'))
      printf("Serial number       : %02X%02X-%02X%02X\n\n",
                              (unsigned char) bootsector[0x2a],
                              (unsigned char) bootsector[0x29],
                              (unsigned char) bootsector[0x28],
                              (unsigned char) bootsector[0x27]);
}
 
Additional reference words: kbinf 5.10 6.00 6.00a 6.00ax 7.00 1.00
1.50
KBCategory: kbprg
KBSubcategory: CRTIss
=============================================================================
Copyright Microsoft Corporation 1995.
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:has
ID: 1314573
Again I believe there is easier way now. I was able to find that reference,
and it says we can use GeVolumeInformation() API to get disk
volume information, if you can try this and see if you get the same
serial no of the disk, please let me know asap. thanks.
0
 
LVL 4

Expert Comment

by:tflai
ID: 1314574
Yep!  I did get the same serial number.  (Except that the high and low WORD are reversed.)
0
 

Author Comment

by:has
ID: 1314575
There is a SetVolumeLabel()  API but I do not believe one can change
the serial no. it is given (randomly !) when the disk is formatted.
if not so please let me know. thanks
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 93
deburging in oracle form 12 99
wait notify demo infinite loop 3 110
Can not remove SSL certificate on iPhone 6 - iOS10.2 12 572
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

810 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