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. GetVolumeInformation not giving any information its return error code 123

GetVolumeInformation not giving any information its return error code 123

Scheduled Pinned Locked Moved C / C++ / MFC
help
6 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.
  • C Offline
    C Offline
    chandrakar ashish
    wrote on last edited by
    #1

    Hi any one plese help me i am using GetVolumeInformation in my code for comressing some files and folder. the used code is below CString strDir = _T("D:\\CompressionTest"); TCHAR volBuff[256]; LPTSTR lpVolumeNameBuffer = volBuff; DWORD nVolumeNameSize = 256; LPDWORD lpVolumeSerialNumber; LPDWORD lpMaximumComponentLength; LPDWORD lpFileSystemFlags = 0; TCHAR sysFileBuff[256]; LPTSTR lpFileSystemNameBuffer = sysFileBuff; DWORD nFileSystemNameSize = 256; if(!GetVolumeInformation(strDir,lpVolumeNameBuffer,nVolumeNameSize,lpVolumeSerialNumber, lpMaximumComponentLength,lpFileSystemFlags,lpFileSystemNameBuffer,nFileSystemNameSize)) { CHAR szBuf[80]; DWORD dw = GetLastError(); sprintf(szBuf, "failed: GetLastError returned %u\n",dw); MessageBox(NULL, szBuf, "Error", MB_OK); ExitProcess(dw); } plese inform me if i am doing any mistakes :confused::thumbsdown:

    _ D 2 Replies Last reply
    0
    • C chandrakar ashish

      Hi any one plese help me i am using GetVolumeInformation in my code for comressing some files and folder. the used code is below CString strDir = _T("D:\\CompressionTest"); TCHAR volBuff[256]; LPTSTR lpVolumeNameBuffer = volBuff; DWORD nVolumeNameSize = 256; LPDWORD lpVolumeSerialNumber; LPDWORD lpMaximumComponentLength; LPDWORD lpFileSystemFlags = 0; TCHAR sysFileBuff[256]; LPTSTR lpFileSystemNameBuffer = sysFileBuff; DWORD nFileSystemNameSize = 256; if(!GetVolumeInformation(strDir,lpVolumeNameBuffer,nVolumeNameSize,lpVolumeSerialNumber, lpMaximumComponentLength,lpFileSystemFlags,lpFileSystemNameBuffer,nFileSystemNameSize)) { CHAR szBuf[80]; DWORD dw = GetLastError(); sprintf(szBuf, "failed: GetLastError returned %u\n",dw); MessageBox(NULL, szBuf, "Error", MB_OK); ExitProcess(dw); } plese inform me if i am doing any mistakes :confused::thumbsdown:

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      you are missing a trailing "\" For eg: CString strDir = _T("D:\\CompressionTest**\\**"); Error code 123 indicates: From MSDN: ERROR_INVALID_NAME 123 (0x7B) The filename, directory name, or volume label syntax is incorrect.

      You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_

      modified on Wednesday, April 15, 2009 5:04 AM

      C 1 Reply Last reply
      0
      • _ _AnsHUMAN_

        you are missing a trailing "\" For eg: CString strDir = _T("D:\\CompressionTest**\\**"); Error code 123 indicates: From MSDN: ERROR_INVALID_NAME 123 (0x7B) The filename, directory name, or volume label syntax is incorrect.

        You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_

        modified on Wednesday, April 15, 2009 5:04 AM

        C Offline
        C Offline
        chandrakar ashish
        wrote on last edited by
        #3

        i tried trailing "\" like below CString strDir = _T("D:\\CompressionTest\"); then its giving compilation error D:\AcqUT\TestZip\TestZip.cpp(27) : error C2001: newline in constant D:\AcqUT\TestZip\TestZip.cpp(27) : fatal error C1057: unexpected end of file in macro expansion while using trailing '\' CString strDir = _T("D:\\CompressionTest'\'"); no compilation error but mentioned problem was not resolved

        _ 1 Reply Last reply
        0
        • C chandrakar ashish

          i tried trailing "\" like below CString strDir = _T("D:\\CompressionTest\"); then its giving compilation error D:\AcqUT\TestZip\TestZip.cpp(27) : error C2001: newline in constant D:\AcqUT\TestZip\TestZip.cpp(27) : fatal error C1057: unexpected end of file in macro expansion while using trailing '\' CString strDir = _T("D:\\CompressionTest'\'"); no compilation error but mentioned problem was not resolved

          _ Offline
          _ Offline
          _AnsHUMAN_
          wrote on last edited by
          #4

          you need to use a "\\" in the end _T("D:\\CompressionTest**\\**"); otherwise you are putting a escape sequence

          You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_

          1 Reply Last reply
          0
          • C chandrakar ashish

            Hi any one plese help me i am using GetVolumeInformation in my code for comressing some files and folder. the used code is below CString strDir = _T("D:\\CompressionTest"); TCHAR volBuff[256]; LPTSTR lpVolumeNameBuffer = volBuff; DWORD nVolumeNameSize = 256; LPDWORD lpVolumeSerialNumber; LPDWORD lpMaximumComponentLength; LPDWORD lpFileSystemFlags = 0; TCHAR sysFileBuff[256]; LPTSTR lpFileSystemNameBuffer = sysFileBuff; DWORD nFileSystemNameSize = 256; if(!GetVolumeInformation(strDir,lpVolumeNameBuffer,nVolumeNameSize,lpVolumeSerialNumber, lpMaximumComponentLength,lpFileSystemFlags,lpFileSystemNameBuffer,nFileSystemNameSize)) { CHAR szBuf[80]; DWORD dw = GetLastError(); sprintf(szBuf, "failed: GetLastError returned %u\n",dw); MessageBox(NULL, szBuf, "Error", MB_OK); ExitProcess(dw); } plese inform me if i am doing any mistakes :confused::thumbsdown:

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

            chandrakar ashish wrote:

            CHAR szBuf[80]; DWORD dw = GetLastError(); sprintf(szBuf, "failed: GetLastError returned %lu\n",dw); MessageBox(NULL, szBuf, "Error", MB_OK);

            It's not a mistake per se, but since you are using MFC, why not have: CString szBuf; DWORD dw = GetLastError(); szBuf.Format("failed: GetLastError returned %u\n",dw); AfxMessageBox(szBuf);

            "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            B 1 Reply Last reply
            0
            • D David Crow

              chandrakar ashish wrote:

              CHAR szBuf[80]; DWORD dw = GetLastError(); sprintf(szBuf, "failed: GetLastError returned %lu\n",dw); MessageBox(NULL, szBuf, "Error", MB_OK);

              It's not a mistake per se, but since you are using MFC, why not have: CString szBuf; DWORD dw = GetLastError(); szBuf.Format("failed: GetLastError returned %u\n",dw); AfxMessageBox(szBuf);

              "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              B Offline
              B Offline
              binyo66
              wrote on last edited by
              #6

              I have the same problem, and I am not using MFC. From several partiotins that I have, the GetVolumeInformation failed 2x. Using the FormatMessage char *errorBuf = 0; if ( FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), //the error message MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &errorBuf, 0, NULL) ) { MessageBox (NULL, errorBuf, "BuildIndex - Error",MB_OK); LocalFree (errorBuf); } The message box says "The filename, directory name, or volume label syntax is incorrect" But explorer shows the right label for those partitions.:confused: So It must be another way to collect information and getting the right label. ==== EDIT ==== Never mind, I got the answer. I added '\\' to the drive name. The funny thing was, It was successfully without adding the '\\' on some partitions :laugh:

              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