Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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

Posted on 1999-07-20
Medium Priority
Last Modified: 2013-12-03
How can I get the physical drive number (e.g. 0x80) from a logical drive (e.g. "C:\")?

Thank you!!
Question by:drdt3
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Author Comment

ID: 1403339
Edited text of question.
LVL 14

Accepted Solution

AlexVirochovsky earned 880 total points
ID: 1403340
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


Author Comment

ID: 1403341
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!!!   :-)
LVL 14

Expert Comment

ID: 1403342
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); = 0x440D;                  //
  regs.x.bx = 3;                  //disk c = 0x6F; = 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;

Author Comment

ID: 1403343
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!

Featured Post

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

704 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