Option Explicit ' 模块类容
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
Public Function WhichFileSystem(ByVal Drive As String) As String
Dim sVolBuf As String * 255, sSysName As String * 255
Dim lSerialNum As Long, lSysFlags As Long
Dim lComponentLength As Long
Dim lRes As Long
lRes = GetVolumeInformation(Drive, sVolBuf, 255, lSerialNum, _
lComponentLength, lSysFlags, sSysName, 255)
If lRes Then
WhichFileSystem = Left$(sSysName, InStr(sSysName, Chr$(0)) - 1)
Else
WhichFileSystem = ""
End If
End Function
'-----------------------------------------------------------------------------
'调用方法:
'在程序中要使用时,只需输入硬盘代号即可,如下:
Private Sub Command1_Click()
MsgBox WhichFileSystem("f:\")
End Sub
评论