开发者

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

开发者 https://www.devze.com 2022-11-30 14:53 出处:网络 作者: mdxy-dxy
这篇文章主要介绍了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 = "Re编程客栈movable"  '移动硬盘
   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 Show编程客栈FreeSpace(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
mewww.devze.comssage = ShowFreeSpace("F:\Programming\Applications")
MsgBox message

开发者_开发培训

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号