虚位以待(AD)
虚位以待(AD)
首页 > 脚本专栏 > vbs > vbs判断磁盘类型和检测硬盘剩余空间的实现代码

vbs判断磁盘类型和检测硬盘剩余空间的实现代码
类别:vbs   作者:码皇   来源:互联网   点击:

这篇文章主要介绍了vbs判断磁盘类型和检测硬盘剩余空间的实现代码,需要的朋友可以参考下

核心代码:

    Function ShowDriveType(drvpath) Dim fso, d, t Set fso = CreateObject("Scripting.FileSystemObject") Set d = fso.GetDrive(fso.GetDriveName(drvpath)) Select Case d.DriveType Case 0 t = "Unknown" Case 1 t = "Removable" '移动硬盘 Case 2 t = "Fixed" '硬盘 Case 3 t = "Network" '网络硬盘 Case 4 t = "CD-ROM" Case 5 t = "RAM Disk" 'RAM End Select ShowDriveType = "Drive " & d.DriveLetter & ": - " & tEnd Function Function ShowFreeSpace(drvPath) Dim fso, d, s Set fso = CreateObject("Scripting.FileSystemObject") Set d = fso.GetDrive(fso.GetDriveName(drvPath)) 'd为F: s = "Drive " & UCase(drvPath) & " - " s = s & d.VolumeName & " " s = s & "Free Space: " & FormatNumber(d.FreeSpace/1024, 0) s = s & " KBytes" ShowFreeSpace = sEnd Function Dim message message = ShowDriveType("F:ProgrammingApplications")MsgBox messagemessage = ShowFreeSpace("F:ProgrammingApplications")MsgBox message

相关热词搜索: vbs 磁盘类型 硬盘剩余空间