• Welcome to Jose's Read Only Forum 2023.
 

Volume Management Functions Examples

Started by José Roca, August 29, 2011, 03:10:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca

 
Volumes are implemented by a device driver called a volume manager. Examples include the FtDisk Manager, the Logical Disk Manager (LDM), and the VERITAS Logical Volume Manager (LVM). Volume managers provide a layer of physical abstraction, data protection (using some form of RAID), and performance.

José Roca

 
The following example illustrates the use of the GetDriveType function.


' ########################################################################################
' The following example illustrates the use of the GetDriveType function.
' ########################################################################################

#COMPILE EXE
#DIM ALL
#INCLUDE "windows.inc"

' ========================================================================================
' Main
' ========================================================================================
FUNCTION PBMAIN () AS LONG

   LOCAL dwBufLen AS DWORD
   LOCAL strBuffer AS STRING
   LOCAL nDrives aS LONG
   LOCAL szDrive AS ASCIIZ * 4
   LOCAL i AS LONG

   ' Retrieve the need buffer length
   dwBufLen = GetLogicalDriveStrings(0, BYVAL %NULL)
   ' Prepare a long enough buffer
   strBuffer = STRING$(dwBufLen, $NUL)
   ' Get the list of drives
   GetLogicalDriveStrings(dwBufLen, BYVAL STRPTR(strBuffer))
   ' Trim the last two nuls
   strBuffer = RTRIM$(strBuffer, $NUL)
   ' Retrieve the number of drives in the list
   nDrives = PARSECOUNT(strBuffer, $NUL)
   ' Parse the list
   FOR i = 1 TO nDrives
      szDrive = PARSE$(strBuffer, $NUL, i)
      SELECT CASE GetDriveType(szDrive)
         CASE %DRIVE_FIXED    : ? szDrive & " Type: Fixed"
         CASE %DRIVE_REMOTE   : ? szDrive & " Type: Remote"
         CASE %DRIVE_REMOVABLE: ? szDrive & " Type: Removable"
         CASE %DRIVE_CDROM    : ? szDrive & " Type: CD-ROM"
         CASE %DRIVE_RAMDISK  : ? szDrive & " Type: RAMDISK"
         CASE ELSE            : ? szDrive & " Type: Unknown Type"
      END SELECT
   NEXT

   #IF %DEF(%PB_CC32)
      WAITKEY$
   #ENDIF

END FUNCTION
' ========================================================================================


José Roca

 
The following example illustrates the use of the GetLogicalDrives function.


#COMPILE EXE
#DIM ALL
#INCLUDE "windows.inc"

FUNCTION PBMAIN () AS LONG

   LOCAL nMask AS LONG
   LOCAL i AS LONG
   
   nMask = GetLogicalDrives
   FOR i = 0 TO 25
      IF BIT(nMask, i) THEN
         ? "Drive: " & CHR$(i + 65)
      END IF
   NEXT
   
   #IF %DEF(%PB_CC32)
      WAITKEY$
   #ENDIF

END FUNCTION


José Roca

 
The following example illustrates the use of the GetLocalDriveStrings function.


' ########################################################################################
' The following example illustrates the use of the GetLogicalDriveStrings function.
' ########################################################################################

#COMPILE EXE
#DIM ALL
#INCLUDE "windows.inc"

' ========================================================================================
' Main
' ========================================================================================
FUNCTION PBMAIN () AS LONG

   LOCAL dwBufLen AS DWORD
   LOCAL strBuffer AS STRING
   LOCAL nDrives aS LONG
   LOCAL strDrive AS STRING
   LOCAL i AS LONG

   ' Retrieve the need buffer length
   dwBufLen = GetLogicalDriveStrings(0, BYVAL %NULL)
   ' Prepare a long enough buffer
   strBuffer = STRING$(dwBufLen, $NUL)
   ' Get the list of drives
   GetLogicalDriveStrings(dwBufLen, BYVAL STRPTR(strBuffer))
   ' Trim the last two nuls
   strBuffer = RTRIM$(strBuffer, $NUL)
   ' Retrieve the number of drives in the list
   nDrives = PARSECOUNT(strBuffer, $NUL)
   ' Parse the list
   FOR i = 1 TO nDrives
      strDrive = PARSE$(strBuffer, $NUL, i)
      ? strDrive
   NEXT

   #IF %DEF(%PB_CC32)
      WAITKEY$
   #ENDIF

END FUNCTION
' ========================================================================================