VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 获得分区信息并判断是否有CD
发表评论(0)作者:, 平台:, 阅读:8304, 日期:2000-03-12
获得分区信息并判断是否有CD

声明:

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


Declare Function GetDriveType Lib "kernel32" _

Alias "GetDriveTypeA" (ByVal nDrive As String) As Long


Public Const DRIVE_CDROM = 5

使用:

Dim VolName As String, FSys As String, erg As Long

Dim VolNumber As Long, MCM As Long, FSF As Long

Dim Drive As String, DriveType As Long

VolName = Space(127)

FSys = Space(127)

Drive = "F:\" 'Enter the driverletter you want

DriveType& = GetDriveType(Drive$)

erg& = GetVolumeInformation(Drive$, VolName$, 127&, _

VolNumber&, MCM&, FSF&, FSys$, 127&)

Print "分区名称:" & vbTab & VolName$

Print "序列号:" & vbTab & VolNumber&

Print "最大文件名称长:" & vbTab & vbTab & MCM&

Print "文件系统标志:" & vbTab & vbTab & FSF&

Print "文件系统名称:" & vbTab & FSys$

Print "类型:" & vbTab & DriveType&;

'Is the drive a CDROM, if so, check for a CD

If DriveType& = DRIVE_CDROM Then

Print " (CDROM, ";

If erg& = 0 Then

Print "没有 CD )"

Else

Print "有 CD )"

End If

Else

Print " (非 CDROM)"

End If