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

D:\ -> 0x80 or -> 0x81

How can I get the physical drive number (e.g. 0x80) from a logical drive (e.g. "C:\")?

Thank you!!
  • 3
  • 2
1 Solution
drdt3Author Commented:
Edited text of question.
1. Easy way: 1-st hard disk 0x80, 2-nd 0x81, ...
2. Not so easy:
  fill DRIVE_MAP_INFO struction:
:Interrupt 21h Function 440Dh Minor Code 6Fh    

Retrieves information about the specified drive.

mov ax, 440Dh            ; generic IOCTL
mov bx, DriveNum         ; see below
mov ch, 8                ; device category
mov cl, 6Fh              ; Get Drive Map Info
mov dx, seg DriveMapInfo ; see below
mov ds, dx
mov dx, offset DriveMapInfo
int 21h
jc  error



Drive to obtain information about. This parameter can be 0 for the default drive, 1 for A, 2 for B, and so on.


Address of the DRIVE_MAP_INFO structure that receives information about the specified drive.

In  DRIVE_MAP_INFO structure
member dmiInt13Unit contents Phisical Drive Number.
I hope, this helps. Alex

drdt3Author Commented:
Alex, sounds good. That answers the first half of my question (win9x). So 222 points are yours. But how about winNT?

Thank you very much!!!   :-)
I send you programm in C in Dos(that , i hope, works in
NT , too). But i hav't NT and can't test it and rewrite
this for NT, sorry.
void cdecl main (void)
  struct SREGS sregs;
  union  REGS regs;
  char   DriveMapInfo[20];
  int    i;
  memset(DriveMapInfo, 0, sizeof(DriveMapInfo));
  DriveMapInfo[0] = 20;
  clrscr ();                              //clear screen
                              //clear all
  memset(&sregs , 0, sizeof(sregs));
  memset(&regs , 0, sizeof(regs));

  sregs.ds = FP_SEG(DriveMapInfo);
  regs.x.dx = FP_OFF(DriveMapInfo);
  regs.x.ax = 0x440D;                  //
  regs.x.bx = 3;                  //disk c
  regs.h.cl = 0x6F;
  regs.h.ch = 8;
  int86x(0x21, &regs, &regs, &sregs);      //read
  if ( _doserrno == 0)
      char c = DriveMapInfo[3];
      char ss[3];
      i = abs(c>>4);
      ss[0] = '0' + i;
      i = c - i*16;
      ss[1] = '0' + abs(i);
      ss[2] = 0;
drdt3Author Commented:
It doesn't work for NT. But cause I didn't say in my original question, that I need it for both win9x and NT, I'll accept your answer... Thanx for your help!
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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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