Declare Function GetDriveType Lib "kernel32" Alias "GetDriveTypeA" (ByVal nDrive As String) As Long
该函数返回系统驱动器类型,返回值为5即为光驱,下面这个例子仅作简单的演示,你可以做进一步的改进以用在您自己的应用程序当中
Private Sub GetCDRomLetter()
Dim DriveNum As Integer
Dim DriveType
Dim CDRom As Integer
Dim DriveLetter As String
Dim i As Byte
DriveNum = 1
Do
DriveNum = DriveNum + 1
DriveLetter = Chr(DriveNum + 65) + ":\"
DriveType = GetDriveType(DriveLetter)
If DriveType = DRIVE_CDROM Then Debug.Print DriveLetter'DRIVE_CDROM=5
Loop Until DriveType = 1'返回值为1,已无可用驱动器
End Sub
文章来源于领测软件测试网 https://www.ltesting.net/
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073