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

2 Responses 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… […]

  2. I purchased TLAM in the Kindle edition. I want to follow the “Marathon: End It” plan for any marathon in March,
    but I am a “hard-copy” type of girl when subsequent a instruction program.
    Are you able to offer any suggestions for trying to print
    out the plan or every other ideas for acquiring a replica I’m
    able to place on my fridge? Thanks!

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,134 other followers

%d bloggers like this: