45fan.com - 路饭网

搜索: 您的位置主页 > 网络频道 > 阅读资讯:如何通过vbs判断磁盘类型和检测硬盘剩余空间的实现代码?

如何通过vbs判断磁盘类型和检测硬盘剩余空间的实现代码?

2016-11-21 11:21:06 来源:www.45fan.com 【

如何通过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 & ": - " & t
End 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 = s
End Function
 
Dim message
 
message = ShowDriveType("F:\Programming\Applications")
MsgBox message
message = ShowFreeSpace("F:\Programming\Applications")
MsgBox message

本文地址:http://www.45fan.com/a/question/83641.html
Tags: 判断 磁盘 VBS
编辑:路饭网
关于我们 | 联系我们 | 友情链接 | 网站地图 | Sitemap | App | 返回顶部