程序代码: | [ 复制代码 ] |
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 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
相关链接:vb,磁盘,文件系统
[本日志由 admin 于 2013-11-01 11:01 PM 编辑]
引用通告地址 (0):
http://www.cnng.net/blog/trackback.asp?tbID=65
http://www.cnng.net/blog/trackback.asp?tbID=65&CP=GBK
http://www.cnng.net/blog/trackback.asp?tbID=65
http://www.cnng.net/blog/trackback.asp?tbID=65&CP=GBK