TVolumeInformation 1.01 from Andrea Mennini
-------------------------------------------

TVolumeInformation is a non visual component that encapsulates Win32's
GetVolumeInformation function API.

TVolumeInformation is Copyright (C) 1997 Andrea Mennini

This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Library General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option) any
later version.

This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the GNU Library General Public License for
more details.

You should have received a copy of the GNU Library General Public License
along with this library in the file LGPL.TXT; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Version: 1.01
Date: Jul 23, 1997

Comments, suggestions, enhancements and bug reports are obviously welcome.

The author can be contacted at the following addresses:

  Snail mail:

    Andrea Mennini
    via E. Manfredi 2/2
    I-40138 Bologna BO
    Italy

  E-mail:
    jake@blues.dsnet.it


System Requirements:
--------------------
This component uses and requires Win32 support. Therefore, it runs under
Delphi 3.0 and 2.0x, or under Delphi 1.0 with Win32 support installed under
Windows 3.1x. By the way, this component has been tested only under Windows95
build 950 and Windows NT Workstation 4.0 build 1381 Service Pack 3. Any
report about its behaviour under other environments will be appreciated.


Installation
------------
Unzip VOLINFO.ZIP into your components directory with the command:

  PKUNZIP -D VOLINFO.ZIP

This will produce the following tree:

 <Components Directory> |
                        |-<other components you have>
                        |- VOLINFO |
                                   |-TESTPRJ
                       

Then, run Delphi, choose Component | Install..., click on Add and select
VOLINFO.PAS. Click on Ok twice, and the TVolumeInformation component will be
installed in the 'Samples' Palette.

If you wish, you can test that everything is alright by running the demo
program TESTPRJ, that is located in the subdirectory with the same name.


Description:
------------
The TVolumeInformation is a TObject descendant that encapsulates the Win32s
GetVolumeInformation API.

The GetVolumeInformation function returns information about a file system and
volume whose root directory is specified.

BOOL GetVolumeInformation(

    LPCTSTR  lpRootPathName,            // address of root directory of the
                                        // file system
    LPTSTR  lpVolumeNameBuffer,	     	// address of name of the volume 
    DWORD  nVolumeNameSize,		// length of lpVolumeNameBuffer 
    LPDWORD  lpVolumeSerialNumber,	// address of volume serial number 
    LPDWORD  lpMaximumComponentLength,  // address of system's maximum filename
                                        // length
    LPDWORD  lpFileSystemFlags,		// address of file system flags 
    LPTSTR  lpFileSystemNameBuffer,	// address of name of file system 
    DWORD  nFileSystemNameSize 		// length of lpFileSystemNameBuffer 
   );	

Parameters


lpRootPathName

  Points to a string that contains the root directory of the volume to be
  described. If this parameter is NULL, the root of the current directory is
  used.

lpVolumeNameBuffer

  Points to a buffer that receives the name of the specified volume. 

nVolumeNameSize

  Specifies the length, in characters, of the volume name buffer. This
  parameter is ignored if the volume name buffer is not supplied.

lpVolumeSerialNumber

  Points to a variable that receives the volume serial number. This parameter
  can be NULL if the serial number is not required.

lpMaximumComponentLength

  Points to a doubleword value that receives the maximum length, in characters,
  of a filename component supported by the specified file system. A filename
  component is that portion of a filename between backslashes.
  The value stored in variable pointed to by *lpMaximumComponentLength is used
  to indicate that long names are supported by the specified file system. For
  example, for a FAT file system supporting long names, the function stores the
  value 255, rather than the previous 8.3 indicator. Long names can also be
  supported on systems that use the NTFS and HPFS file systems.
 
lpFileSystemFlags

  Points to a doubleword that receives flags associated with the specified file
  system. This parameter can be any combination of the following flags, with
  one exception: FS_FILE_COMPRESSION and FS_VOL_IS_COMPRESSED are mutually
  exclusive.

Value	                        Meaning
------------------------------------------------------------------------------
FS_CASE_IS_PRESERVED            If this flag is set, the file system preserves
                                the case of filenames when it places a name on
                                disk.
FS_CASE_SENSITIVE               If this flag is set, the file system supports
                                case-sensitive filenames.
FS_UNICODE_STORED_ON_DISK       If this flag is set, the file system supports
                                Unicode in filenames as they appear on disk.
FS_PERSISTENT_ACLS              If this flag is set, the file system preserves
                                and enforces ACLs. For example, NTFS preserves
                                and enforces ACLs, HPFS and FAT do not.
FS_FILE_COMPRESSION             The file system supports file-based
                                compression.
FS_VOL_IS_COMPRESSED            The specified volume is a compressed volume;
                                for example, a DoubleSpace volume.

lpFileSystemNameBuffer

  Points to a buffer that receives the name of the file system (such as FAT,
  HPFS, or NTFS).

nFileSystemNameSize

  Specifies the length, in characters, of the file system name buffer. This
  parameter is ignored if the file system name buffer is not supplied.

Return Value

  If all the requested information is retrieved, the return value is TRUE;
  otherwise, it is FALSE. To get extended error information, call GetLastError.

Remarks

The FS_VOL_IS_COMPRESSED flag is the only indicator of volume-based compression. The file system name is not altered to indicate compression. This flag comes back set on a DoubleSpace volume, for example. With volume-based compression, an entire volume is either compressed or not compressed.

The FS_FILE_COMPRESSION flag indicates whether a file system supports
file-based compression. With file-based compression, individual files can be
compressed or not compressed.

The FS_FILE_COMPRESSION and FS_VOL_IS_COMPRESSED flags are mutually exclusive;
both bits cannot come back set.

The maximum component length value, stored in the DWORD variable pointed to by
lpMaximumComponentLength, is the only indicator that a volume supports
longer-than-normal FAT (or other file system) file names. The file system name
is not altered to indicate support for long file names.
The GetCompressedFileSize function obtains the compressed size of a file. The
GetFileAttributes function can determine whether an individual file is
compressed.

Note:
-----

lpRootPathName can be either a local or network mapped file name, or an UNC
file name. This means that it could have the form

  <driveletter>:\

where driveletter is both a local drive or a network mapped drive, or

  \\<servername>\<sharename>

In this last case, due to a bug in Windows NT, the UNC name must have an extra
backslash at its end, e.g. it MUST be of the form:

  \\<servername>\<sharename>\


Use:
----
To use it, the only thing you have to do is to drag the component onto your
form and set the Drive property.

TVolumeInformation has only three properties:

  Drive: string

  The Drive property determinates on which drive the GetVolumeName is
  performed.
  Warning: no check is made on this property! Therefore you'd better be sure
  that the drive supplied exists.

  UNCDrive: string

  Run-time and read only. The UNCDrive property contains the root file path of
  the drive selected by setting the Drive property. If Drive is a local drive,
  UNCDrive is a path of the form:

    <driveletter>:\

  If Drive is a networked drive, UNCDrive is a real UNC path of the form:

    \\<servername>\<sharename>

  Version: string
  Run-time and read only. The Version string returns the component version.

TVolumeInformation has the following methods:

  CaseIsPreserved: boolean

    The CaseIsPreserved method returns True if the file system flag
    FS_CASE_IS_PRESERVED is set, False otherwise.
  

  CaseSensitive: boolean

    The CaseSensitive method returns True if the file system flag
    FS_CASE_SENSITIVE is set, False otherwise.


  UnicodeStoredOnDisk: boolean
    
    The UnicodeStoredOnDisk method returns True if the file system flag
    FS_UNICODE_STORED_ON_DISK is set, False otherwise.


  PersistentACLs: boolean

    The PersistentACLs method returns True if the file system flag
    FS_PERSISTENT_ACLS is set, False otherwise.


  SupportsFileCompression: boolean

    The SupportsFileCompression method returns True if the file system flag
    FS_FILE_COMPRESSION is set, False otherwise.


  VolumeIsCompressed: boolean
 
    The VolumeIsCompressed method returns True if the file system flag
    FS_VOL_IS_COMPRESSED is set, False otherwise.


  VolumeFileSystemFlags: integer 

    The VolumeFileSystemFlags method returns an integer that contains the flags
    associated with the file system.


  VolumeFileSystemName: string

    The VolumeFileSystemName method returns a string containing the file
    system name, such as FAT, HPFS, or NTFS;


  VolumeLabel: string 

   The VolumeLabel method returns a string containing the volume label.


  VolumeSerialNumber: string

    The VolumeSerialNumber method returns a string containing the volume serial
    number.


TVolumeInformation has only one event:

    OnError

      The OnError event is triggered when an error occurs in the
      GetVolumeInformation call. If there is an user event defined, i.e. the
      user has choosen in the object inspector or at run-time its own event
      handler, then it is executed and the receives the error code (an integer
      value) returned by GetLastError API.

      Otherwise, a default error alert box pops up.
 
