VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 找到 CD-ROM 驱动器号
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:8449, 日期:2001-06-04
找到 CD-ROM 驱动器号  
下面的函数将检查你计算机所有的驱动器看是否是 CD-ROM,如果是就返回驱动器号,如果没有就返回空字符:
Public Function BI_GetCDROMDrive() As String
    Dim lType As Long
    Dim i As Integer
    Dim tmpDrive As String
    Dim found As Boolean
    On Error GoTo ErrorHandler
    注释:Loop thru A-Z. If found, exit early.
    For i = 0 To 25
        tmpDrive = Chr(65 + i) & ":\"
        lType = GetDriveType(tmpDrive)     注释:Win32 API 函数
        If (lType = DRIVE_CDROM) Then     注释:Win32 API 常数
            found = True
            Exit For
        End If
    Next
    If Not found Then
        tmpDrive = ""
    End If
    BI_GetCDROMDrive = tmpDrive
ErrorHandler:
Err.Description = "BI_GetCDROMDrive 失败:不可预料的错误。"
BI_Errorhandler
End Function