MSSQLWIKI

Karthick P.K on SQL Server

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;
            }

  
}

 
About these ads

One Response to “How to retrieve information about the file system and volume associated with the specified root directory (GetVolumeInformation function)”

  1. […] How to retrieve information about the file system and volume associated with the specified root dire… […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 2,088 other followers

%d bloggers like this: