Author Topic: Volume Management Functions Examples  (Read 4174 times)

0 Members and 1 Guest are viewing this topic.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
Volume Management Functions Examples
« on: August 29, 2011, 03:10:37 AM »
 
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.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
WINAPI: GetDriveType Function
« Reply #1 on: August 29, 2011, 03:11:54 AM »
 
The following example illustrates the use of the GetDriveType function.

Code: [Select]
' ########################################################################################
' 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
' ========================================================================================

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
WINAPI: GetLogicalDrives Function
« Reply #2 on: August 29, 2011, 03:12:50 AM »
 
The following example illustrates the use of the GetLogicalDrives function.

Code: [Select]
#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

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
  • User-Rate: +204/-0
WINAPI: GetLogicalDriveStrings Function
« Reply #3 on: August 29, 2011, 03:13:37 AM »
 
The following example illustrates the use of the GetLocalDriveStrings function.

Code: [Select]
' ########################################################################################
' 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
' ========================================================================================