Link to home
Start Free TrialLog in
Avatar of drdt3
drdt3

asked on

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

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

Thank you!!
Avatar of drdt3
drdt3

ASKER

Edited text of question.
ASKER CERTIFIED SOLUTION
Avatar of AlexVirochovsky
AlexVirochovsky

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of drdt3

ASKER

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;
      printf("0x%s",ss);
      getch();
    }
}
 
Avatar of drdt3

ASKER

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!