home *** CD-ROM | disk | FTP | other *** search
/ Dan Appleman's Visual Bas…s Guide to the Win32 API / Dan.Applmans.Visual.Basic.5.0.Programmers.Guide.To.The.Win32.API.1997.Ziff-Davis.Press.CD / VB5PG32.mdf / vbpg32 / samples5 / ch13 / logdrvs.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-02-16  |  3.9 KB  |  108 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Drive Information"
  4.    ClientHeight    =   3300
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1515
  7.    ClientWidth     =   3930
  8.    LinkTopic       =   "Form1"
  9.    PaletteMode     =   1  'UseZOrder
  10.    ScaleHeight     =   3300
  11.    ScaleWidth      =   3930
  12.    Begin VB.ListBox List2 
  13.       Height          =   1200
  14.       Left            =   240
  15.       TabIndex        =   1
  16.       Top             =   1860
  17.       Width           =   3375
  18.    End
  19.    Begin VB.ListBox List1 
  20.       Height          =   1200
  21.       Left            =   240
  22.       TabIndex        =   0
  23.       Top             =   360
  24.       Width           =   3375
  25.    End
  26.    Begin VB.Label Label2 
  27.       Caption         =   "Volume Information"
  28.       Height          =   195
  29.       Left            =   240
  30.       TabIndex        =   3
  31.       Top             =   1620
  32.       Width           =   3375
  33.    End
  34.    Begin VB.Label Label1 
  35.       Caption         =   "Logical Drives"
  36.       Height          =   195
  37.       Left            =   240
  38.       TabIndex        =   2
  39.       Top             =   120
  40.       Width           =   3015
  41.    End
  42. Attribute VB_Name = "Form1"
  43. Attribute VB_GlobalNameSpace = False
  44. Attribute VB_Creatable = False
  45. Attribute VB_PredeclaredId = True
  46. Attribute VB_Exposed = False
  47. Option Explicit
  48. ' Copyright 
  49.  1997 by Desaware Inc. All Rights Reserved
  50. Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
  51. Private Declare Function GetVolumeInformation Lib "kernel32" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponentLength As Long, lpFileSystemFlags As Long, ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long) As Long
  52. Private Const FS_CASE_IS_PRESERVED = &H2
  53. Private Const FS_CASE_SENSITIVE = &H1
  54. Private Const FS_UNICODE_STORED_ON_DISK = &H4
  55. Private Const FS_PERSISTENT_ACLS = &H8
  56. Private Const FS_FILE_COMPRESSION = &H10
  57. Private Const FS_VOL_IS_COMPRESSED = &H8000
  58. Private Sub Form_Load()
  59.     Dim s$
  60.     Dim n&
  61.     s$ = String$(2048, 0)
  62.     Call GetLogicalDriveStrings(2047, s$)
  63.     Do
  64.         n = InStr(s$, Chr$(0))
  65.         If n > 1 Then
  66.             List1.AddItem Left$(s$, n - 1)
  67.             s$ = Mid$(s$, n + 1)
  68.         End If
  69.     Loop Until n <= 1
  70.     List1.ListIndex = 0
  71. End Sub
  72. Private Sub List1_Click()
  73.     Dim volbuf$, sysname$
  74.     Dim serialnum&, sysflags&, componentlength&
  75.     Dim res&
  76.     List2.Clear
  77.     volbuf$ = String$(256, 0)
  78.     sysname$ = String$(256, 0)
  79.     res = GetVolumeInformation(List1.Text, volbuf$, 255, serialnum, _
  80.             componentlength, sysflags, sysname$, 255)
  81.     If res = 0 Then
  82.         List2.AddItem "Unable to retrieve volume information"
  83.     Else
  84.         List2.AddItem "Volume: " & agGetStringFromLPSTR(volbuf$)
  85.         List2.AddItem "Serial#: " & serialnum
  86.         List2.AddItem "Component Length: " & componentlength
  87.         List2.AddItem "File system: " & agGetStringFromLPSTR(sysname$)
  88.         If sysflags And FS_CASE_IS_PRESERVED Then
  89.             List2.AddItem "Case is preserved"
  90.         End If
  91.         If sysflags And FS_CASE_SENSITIVE Then
  92.             List2.AddItem "File system is case sensitive"
  93.         End If
  94.         If sysflags And FS_UNICODE_STORED_ON_DISK Then
  95.             List2.AddItem "Filenames are stored as Unicode"
  96.         End If
  97.         If sysflags And FS_PERSISTENT_ACLS Then
  98.             List2.AddItem "Access control is supported."
  99.         End If
  100.         If sysflags And FS_FILE_COMPRESSION Then
  101.             List2.AddItem "Individual files may be compressed"
  102.         End If
  103.         If sysflags And FS_VOL_IS_COMPRESSED Then
  104.             List2.AddItem "Entire volume is compressed"
  105.         End If
  106.     End If
  107. End Sub
  108.