Chapter 27: Using the Windows Application Programming Interface
959
case sensitive, and whether the volume supports file-based compression. The return value is 1 if
successful, 0 if not.
The GetVolumeInformation wrapper function accepts a valid path name and a 1 or 2 indicat-
ing whether to return the volume name or file system information, respectively.
Function GetVolumeInfo(PathName As String, _
Selection As Integer) As String
Dim VolName As String * 255
Dim BufferSize As Long
Dim VolSerNo As Long
Dim MaxFileLen As Long
Dim SysFlags As Long
Dim SysName As String * 255
Dim SysBufSize As Long
Dim RetVal As Long
Const Get_Volume_Name = 1
Const Get_File_System = 2
BufferSize = Len(VolName)
SysBufSize = Len(SysName)
RetVal = apiGetVolumeInformation(PathName, _
VolName, BufferSize, VolSerNo, MaxFileLen, _
SysFlags, SysName, SysBufSize)
If Selection = 1 Then
GetVolumeInfo = “Volume Name: “ & Trim(VolName)
Else
If Selection = 2 Then
GetVolumeInfo = “File System: “ & Trim(SysName)
End If
End If
End Function
GetSystemDirectoryA
GetSystemDirectoryA returns the Windows system directory for the current machine.
Declare Function apiGetSystemDirectory _
Lib “Kernel32” _
Alias “GetSystemDirectoryA”( _
ByVal ReturnBuffer As String, _
uiBufferSize As Long) As Long
Upon success, the function returns the number of characters contained in the ReturnBuffer
argument. GetSystemDirectoryA returns zero if unsuccessful. GetSystemDirectory is a
wrapper utilizing GetSystemDirectoryA to return the Windows installation folder.
Function GetSystemDirectory() As String
Dim ReturnBuffer As String * 255
Dim BufferSize As Long
BufferSize = Len(ReturnBuffer)
Dim RetVal As Long