How to retrieve information about the file system and volume associated with the specified root directory (GetVolumeInformation function)
Posted by Karthick P.K on May 30, 2010
#include <windows.h> #include <winbase.h> #include <iostream> using namespace std; void main() { bool x=0; char lpVolumeNameBuffer[1000]; DWORD nVolumeNameSize; DWORD lpVolumeSerialNumber; DWORD lpMaximumComponentLength; DWORD lpFileSystemFlags; char lpFileSystemNameBuffer[1000]; DWORD nFileSystemNameSize; char a[100]; cout<<"A trailing backslash is required when you enter diskname. For example, you specify \\\\MyServer\\\MyShare as \\\\MyServer\\MyShare\\ or\n the C drive as C:\\"; cout<<"\n"<<"Enter the Disk:"; cin>>a; nVolumeNameSize= sizeof( (TCHAR) (lpVolumeNameBuffer))+1; nFileSystemNameSize=sizeof( (TCHAR) (lpFileSystemNameBuffer))+1; x= GetVolumeInformation((LPCSTR)&a, (LPSTR) lpVolumeNameBuffer,256,&lpVolumeSerialNumber,&lpMaximumComponentLength,&lpFileSystemFlags,(LPSTR) lpFileSystemNameBuffer,256); if (x==0) { int e=GetLastError(); printf ( "Error getting volume information, Error ID:"); printf ("%d",e); } else { cout<<"Disk:"<<a; cout<<"\nVolumeNameBuffer:"<<lpVolumeNameBuffer; cout<<"\nVolumeSerialNumber:"<<lpVolumeSerialNumber; cout<<"\nMaximumComponentLength:"<<lpMaximumComponentLength; cout<<"\nFileSystemFlags:"<<lpFileSystemFlags; cout<<"\nFileSystemNameBuffer:"<<lpFileSystemNameBuffer; } }