|
Данный пример позволяет определить серийный
номер диска, метку диска и тип файловой системы
Добавьте CommandButton на форму 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
Const GET_SERIAL = 1
Const GET_LABEL = 2
Const GET_TYPE = 3
Private Function GetDriveInfo(strDrive As String, iType As Integer)
Dim SerialNum As Long
Dim strLabel As String
Dim strType As String
Dim lRetVal As Long
strLabel = Space(256)
strType = Space(256)
lRetVal = GetVolumeInformation(strDrive, strLabel, Len(strLabel), SerialNum, 0, 0,
strType, Len(strType))
Select Case iType
Case Is = 1
GetDriveInfo = CStr(SerialNum)
Case Is = 2
GetDriveInfo = strLabel
Case Is = 3
GetDriveInfo = strType
End Select
End Function
Private Sub Command1_Click()
strValue = GetDriveInfo("c:\", GET_SERIAL)
MsgBox strValue
strValue = GetDriveInfo("c:\", GET_LABEL)
MsgBox strValue
strValue = GetDriveInfo("c:\", GET_TYPE)
MsgBox strValue
End Sub
|
|