CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: C++ Drive List

  1. #1
    Join Date
    Apr 1999
    Location
    VA BEACH
    Posts
    467

    C++ Drive List

    I need to show the user a list of drives to select from, is there an easy way to do this in MFC, or if not with the api?
    TIA

    Jim Hewitt, Liberty Tax Service

  2. #2
    Join Date
    Apr 1999
    Location
    Portland, OR, USA
    Posts
    29

    Re: C++ Drive List

    There's a function called GetLogicalDrives() that will return to you a DWORD containing a bitmask representing the currently available disk drives. Bit position 0 (the least-significant bit) is drive A, bit position 1 is drive B, bit position 2 is drive C, and so on.

    To determine which drives are present, you can do something like this:


    DWORD dwRes = GetLogicalDrives();
    if (0 != dwRes)
    {
    while (dwRes)
    {
    // Check if the bit is a "1" or a "0"
    if (dwRes & 1)
    MessageBox("Found a drive!");

    // Shift the value over by one
    dwRes >>= 1;
    }
    }




    Hope this helps!! Happy coding,

    =================================================
    Valerie L. Bradley
    Software Engineer
    Intel Corporation

    * All opinions expressed are mine and not those of my employer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured