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. Drive Names - Please reply

Drive Names - Please reply

Scheduled Pinned Locked Moved C / C++ / MFC
questionjson
10 Posts 5 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.
  • V Offline
    V Offline
    velayudhan_raj
    wrote on last edited by
    #1

    Hi Guys, This question I asked earlier, but I could nt continue, I want to make it clear, Is there any API by which we can know the local drives of our system ( A:, C:, D: etc )? Please do reply guys. Thanks in Advance Velayudhan

    N 1 Reply Last reply
    0
    • V velayudhan_raj

      Hi Guys, This question I asked earlier, but I could nt continue, I want to make it clear, Is there any API by which we can know the local drives of our system ( A:, C:, D: etc )? Please do reply guys. Thanks in Advance Velayudhan

      N Offline
      N Offline
      Nibu babu thomas
      wrote on last edited by
      #2

      velayudhan_raj wrote:

      This question I asked earlier, but I could nt continue, I want to make it clear, Is there any API by which we can know the local drives of our system ( A:, C:, D: etc )? Please do reply guys.

      GetLogicalDriveStrings();


      Nibu thomas A Developer Programming tips[^]  My site[^]

      V 1 Reply Last reply
      0
      • N Nibu babu thomas

        velayudhan_raj wrote:

        This question I asked earlier, but I could nt continue, I want to make it clear, Is there any API by which we can know the local drives of our system ( A:, C:, D: etc )? Please do reply guys.

        GetLogicalDriveStrings();


        Nibu thomas A Developer Programming tips[^]  My site[^]

        V Offline
        V Offline
        velayudhan_raj
        wrote on last edited by
        #3

        It is not completely successful. It is just returning a single drive's name Actually I want all the name's of all drives in my system. Thanks in Advance Velayudhan

        N C H D 4 Replies Last reply
        0
        • V velayudhan_raj

          It is not completely successful. It is just returning a single drive's name Actually I want all the name's of all drives in my system. Thanks in Advance Velayudhan

          N Offline
          N Offline
          Nibu babu thomas
          wrote on last edited by
          #4

          velayudhan_raj wrote:

          It is not completely successful. It is just returning a single drive's name Actually I want all the name's of all drives in my system.

          You should first read the documentation carefully :) Quote from MSDN... lpBuffer [out] Pointer to a buffer that receives a series of null-terminated strings, one for each valid drive in the system, that end with a second null character. The following example shows the buffer contents with representing the terminating null character. c:\d:\ End quote... I guess you are trying to assign to a string which terminates where it finds a null character, hence you are not able to get the whole drives.


          Nibu thomas A Developer Programming tips[^]  My site[^]

          1 Reply Last reply
          0
          • V velayudhan_raj

            It is not completely successful. It is just returning a single drive's name Actually I want all the name's of all drives in my system. Thanks in Advance Velayudhan

            C Offline
            C Offline
            CraZyToLearn
            wrote on last edited by
            #5

            Dear Velayudhan, I am Listing in LisBox, u can display it in any control. Here is the Code..... unsigned long driveList = GetLogicalDrives(); char drivePathName[] = " :\\"; CString drive; for(int i = 1;i<26; i++) //u can give no of drives in your system { if(0x01 & (driveList >> i)) { drivePathName[0] = 'A' + i; drive.Format("%c",drivePathName[0]); m_List.AddString(drive); } }

            With Best Regards Vidya S/W Developer, AnnetSite,Mumbai

            1 Reply Last reply
            0
            • V velayudhan_raj

              It is not completely successful. It is just returning a single drive's name Actually I want all the name's of all drives in my system. Thanks in Advance Velayudhan

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

              How to use this function char *m_Name=new char[256]; DWORD Lenght=255; GetLogicalDriveStrings(Lenght,m_Name); ... ... -- modified at 10:25 Wednesday 6th September, 2006

              _**


              **_

              WhiteSky


              D 1 Reply Last reply
              0
              • H Hamid Taebi

                How to use this function char *m_Name=new char[256]; DWORD Lenght=255; GetLogicalDriveStrings(Lenght,m_Name); ... ... -- modified at 10:25 Wednesday 6th September, 2006

                _**


                **_

                WhiteSky


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

                WhiteSky wrote:

                How to use this file

                What file?


                "Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.

                "Judge not by the eye but by the heart." - Native American Proverb

                H 1 Reply Last reply
                0
                • V velayudhan_raj

                  It is not completely successful. It is just returning a single drive's name Actually I want all the name's of all drives in my system. Thanks in Advance Velayudhan

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

                  Each drive letter is separated by a nul character. Try:

                  char szDrives[105] = {0};
                  GetLogicalDriveStrings(sizeof(szDrives), szDrives);

                  char *pToken = szDrives;
                  while (*pToken != '\0')
                  {
                  cout << pToken << endl;
                  pToken += 4;
                  }


                  "Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.

                  "Judge not by the eye but by the heart." - Native American Proverb

                  1 Reply Last reply
                  0
                  • D David Crow

                    WhiteSky wrote:

                    How to use this file

                    What file?


                    "Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.

                    "Judge not by the eye but by the heart." - Native American Proverb

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

                    :-O function

                    _**


                    **_

                    WhiteSky


                    D 1 Reply Last reply
                    0
                    • H Hamid Taebi

                      :-O function

                      _**


                      **_

                      WhiteSky


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

                      Fair enough. But the OP already knew how to use the function. He was troubling parsing the resulting buffer.


                      "Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.

                      "Judge not by the eye but by the heart." - Native American Proverb

                      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