时间: 2021-07-31 作者:daque
option explicitprivate declare function getdrivetype lib "kernel32" alias "getdrivetypea" _ (byval ndrive as string) as long解释:getlogicaldrivestrings-->获得一个字串,个中包括了暂时一切论理启动器的根启动器路途private declare function getlogicaldrivestrings lib "kernel32" alias "getlogicaldrivestringsa" _ (byval nbufferlength as long, byval lpbuffer as string) as longprivate const drive_removable = 2private const drive_fixed = 3private const drive_remote = 4private const drive_cdrom = 5private const drive_ramdisk = 6private sub command1_click()dim rtn as stringdim alldrives as stringdim justonedrive as stringalldrives = space$(64) 解释:树立缓冲rtn = getlogicaldrivestrings(len(alldrives), alldrives) 解释:挪用因变量获得包括一切启动器的字符串alldrives = left(alldrives, rtn)do rtn = instr(alldrives, chr(0)) if rtn then 解释:若有的话 justonedrive = left(alldrives, rtn) alldrives = mid(alldrives, rtn + 1, len(alldrives)) rtn = getdrivetype(justonedrive) 解释:查看启动器典型 if rtn = drive_cdrom then 解释:是cd-rom label1.caption = left(ucase(justonedrive), 2) 解释:给label1 exit do end if end ifloop until alldrives = "" or rtn = drive_cdromcommand1.enabled = falseif label1.caption = "" then label1.caption = "没有创造光驱!"end ifend sub