DeclareFunctionGetDriveTypeLib"kernel32"Alias"GetDriveTypeA"(ByValnDriveAsString)AsLong
該函數返回系統驅動器類型,返回值為5即為光驅,下面這個例子僅作簡單的演示,你可以做進一步的改進以用在您自己的應用程序當中
PrivateSubGetCDRomLetter()
DimDriveNumAsInteger
DimDriveType
DimCDRomAsInteger
DimDriveLetterAsString
DimiAsByte
DriveNum=1
Do
DriveNum=DriveNum 1
DriveLetter=Chr(DriveNum 65) ":"
DriveType=GetDriveType(DriveLetter)
IfDriveType=DRIVE_CDROMThenDebug.PrintDriveLetter'DRIVE_CDROM=5
LoopUntilDriveType=1'返回值為1,已無可用驅動器
EndSub->