标题: 如何利用API函数找到CD-ROM驱动器的盘号? [打印本页] 作者: 孙宏雷 时间: 2013-7-2 13:52 标题: 如何利用API函数找到CD-ROM驱动器的盘号? 作者: 淡写轻描 时间: 2013-7-2 13:55
下面的函数将检查你计算机所有的驱动器看是否是 CD-ROM,如果是就返回驱动器号,如果没有就返回空字符Public Function GetCDROMDrive() As String Dim lType As Long,I As Integer,tmpDrive as String,found as BooleanOn Error GoTo errLFor 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 = "" BI_GetCDROMDrive = tmpDrive exit Function errL: msgbox error$ End Function