Advanced PowerBuilder

HomePrevious Lesson: Reading the Value of an Environment Variable
Next Lesson: Writing to the Windows NT Event Log

Finding the Volume Information

Declare a local external function as shown below.
FUNCTION boolean ufx_GetVolumeInformation( &
         ref string lpRootPathName,ref string &
         lpVolumeNameBuffer,ulong nVolumeNameSize, &
         ref ulong lpVolumeSerialNumber,ref ulong &
         lpMaximumComponentLength,ref ulong &
         lpFileSystemFlags,ref string &
         lpFileSystemNameBuffer,ulong &
         nFileSystemNameSize) Library "kernel32.dll" &
         ALIAS FOR "GetVolumeInformationA"

The following code displays the volume information of the specified drive. If you specify 'A:', it will say FAT file system and will show NWCOMPAT when specified a mapped Novell Network volume/drive.
// Object: cb_display_volume_info
// Event: Clicked
String ls_RootPathName             = "c:"
String ls_VolumeNameBuffer         = space(256)
String ls_FileSystemNameBuffer     = space(256)
ulong  lul_VolumeNameSize          = 256
ulong  lul_MaximumComponentLength  = 256
ulong  lul_FileSystemNameSize      = 256
ulong  lul_VolumeSerialNumber
ulong  lul_FileSystemFlags
setnull( lul_VolumeSerialNumber )
setnull( lul_FileSystemFlags )
ufx_GetVolumeInformation(ls_RootPathName, &
      ls_VolumeNameBuffer, lul_VolumeNameSize,&
      lul_VolumeSerialNumber, lul_MaximumComponentLength, &
		   lul_FileSystemFlags,ls_FileSystemNameBuffer, &
		   lul_FileSystemNameSize)
if IsNull( ls_RootPathName ) then ls_RootPathName = 'N/A' 
if IsNull(ls_VolumeNameBuffer) then &
         ls_VolumeNameBuffer = 'N/A' 
if IsNull( lul_VolumeNameSize ) then lul_VolumeNameSize = 0 
if IsNull( lul_VolumeSerialNumber ) then &
           lul_VolumeSerialNumber = 0 
if IsNull( lul_MaximumComponentLength ) then &
           lul_MaximumComponentLength = 0 
if IsNull( lul_FileSystemFlags ) then &
           lul_FileSystemFlags = 0 
if IsNull( ls_FileSystemNameBuffer ) then &
           ls_FileSystemNameBuffer = 'N/A' 
if IsNull( lul_FileSystemNameSize ) then &
           lul_FileSystemNameSize =  0
MessageBox( "Volume Info", &
   "Root Path Name: " + ls_RootPathName + "~n" + &
   "Volume Name : " + ls_VolumeNameBuffer + "~n" + &
   "Volume Size: " + String(lul_VolumeNameSize) + "~n" + &
   "Volume Serial # " + String(lul_VolumeSerialNumber) + &
   "~n" + "Max Component Length : " + &
   String(lul_MaximumComponentLength) + "~n" + &
   "File System Flags : " + String(lul_FileSystemFlags) &
   + "~n" + "File System Name : " +  &
   String(ls_FileSystemNameBuffer) + "~n" + &
   "File System Size : " + String(lul_FileSystemNameSize) )
HomePrevious Lesson: Reading the Value of an Environment Variable
Next Lesson: Writing to the Windows NT Event Log