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 / samples4 / ch13 / logdrvs.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-02-16  |  3.9 KB  |  109 lines

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