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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Enumerating through local drives

Enumerating through local drives

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorial
5 Posts 4 Posters 0 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.
  • J Offline
    J Offline
    JBAK_CP
    wrote on last edited by
    #1

    Hi, I am looking for some information on how to enumerate through the list of available drives on the local machine to be displayed to the user. I remember coming across something similar on CP sometime back, but I am unable to locate it now. If someone could point me in the right direction on where to find some sample code or demo progs., it would be greatly apperciated. I am going to be doing this in VC++ (2003), MFC, on Windows. Thanks

    D S H 3 Replies Last reply
    0
    • J JBAK_CP

      Hi, I am looking for some information on how to enumerate through the list of available drives on the local machine to be displayed to the user. I remember coming across something similar on CP sometime back, but I am unable to locate it now. If someone could point me in the right direction on where to find some sample code or demo progs., it would be greatly apperciated. I am going to be doing this in VC++ (2003), MFC, on Windows. Thanks

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Have you tried GetLogicalDrives() or GetLogicalDriveStrings()?

      "Love people and use things, not love things and use people." - Unknown

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      1 Reply Last reply
      0
      • J JBAK_CP

        Hi, I am looking for some information on how to enumerate through the list of available drives on the local machine to be displayed to the user. I remember coming across something similar on CP sometime back, but I am unable to locate it now. If someone could point me in the right direction on where to find some sample code or demo progs., it would be greatly apperciated. I am going to be doing this in VC++ (2003), MFC, on Windows. Thanks

        S Offline
        S Offline
        Stephen Hewitt
        wrote on last edited by
        #3

        Try something like this:

        // VanillaConsole.cpp : Defines the entry point for the console application.
        //
         
        #include "stdafx.h"
        #include <windows.h>
        #include <iostream>
        using namespace std;
         
        int main()
        {
        DWORD mask = GetLogicalDrives();
        for (char letter='A'; mask!=0; mask=mask>>1, letter+=1)
        {
        if (mask & 1)
        {
        cout << letter << ":" << endl;
        }
        }
         
        return 0;
        }

        Steve

        J 1 Reply Last reply
        0
        • S Stephen Hewitt

          Try something like this:

          // VanillaConsole.cpp : Defines the entry point for the console application.
          //
           
          #include "stdafx.h"
          #include <windows.h>
          #include <iostream>
          using namespace std;
           
          int main()
          {
          DWORD mask = GetLogicalDrives();
          for (char letter='A'; mask!=0; mask=mask>>1, letter+=1)
          {
          if (mask & 1)
          {
          cout << letter << ":" << endl;
          }
          }
           
          return 0;
          }

          Steve

          J Offline
          J Offline
          JBAK_CP
          wrote on last edited by
          #4

          thank you!

          1 Reply Last reply
          0
          • J JBAK_CP

            Hi, I am looking for some information on how to enumerate through the list of available drives on the local machine to be displayed to the user. I remember coming across something similar on CP sometime back, but I am unable to locate it now. If someone could point me in the right direction on where to find some sample code or demo progs., it would be greatly apperciated. I am going to be doing this in VC++ (2003), MFC, on Windows. Thanks

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            See System Information Utility[^].

            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