Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Mapping logical drive to its physical drive

Mapping logical drive to its physical drive

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VCProgrammer
    wrote on last edited by
    #1

    Hi all, I want to map logical drive to its physical drive value i.e. if i give c: it should tell its hard disk number and partition number. For example if i give C: it should give \Device\HardDiskVolume1. For doing so i have used QueryDosDevice but it is not giving me correct answer. Here is my code

    CString text;
    GetDlgItemText(IDC_EDIT1,text);

    TCHAR szBuffer[MAX_PATH];
    bool bIsFloppy = false;

    if (QueryDosDevice(text, szBuffer, MAX_PATH) > 0)
    {
    CString buffer = szBuffer;
    AfxMessageBox(buffer);
    }

    But my code is giving incorrect result \Device\HardDiskVolume11 Can anybody please tell me what i am doing wrong?

    L 1 Reply Last reply
    0
    • V VCProgrammer

      Hi all, I want to map logical drive to its physical drive value i.e. if i give c: it should tell its hard disk number and partition number. For example if i give C: it should give \Device\HardDiskVolume1. For doing so i have used QueryDosDevice but it is not giving me correct answer. Here is my code

      CString text;
      GetDlgItemText(IDC_EDIT1,text);

      TCHAR szBuffer[MAX_PATH];
      bool bIsFloppy = false;

      if (QueryDosDevice(text, szBuffer, MAX_PATH) > 0)
      {
      CString buffer = szBuffer;
      AfxMessageBox(buffer);
      }

      But my code is giving incorrect result \Device\HardDiskVolume11 Can anybody please tell me what i am doing wrong?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Your code is not incorrect; volume names are assigned internally by Windows and do not necessarily follow the order that you expect. There is lots of information in MSDN here[^] that helps to explain it.

      Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups