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