欢迎来到入门教程网!

vb

当前位置:主页 > 软件编程 > vb >

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

来源:本站原创|时间:2020-01-10|栏目:vb|点击:

核心代码:

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

上一篇:ComboBox 控件的用法教程

栏    目:vb

下一篇:VBS实现截图功能

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

本文地址:https://www.xiuzhanwang.com/a1/vb/7156.html

网页制作CMS教程网络编程软件编程脚本语言数据库服务器

如果侵犯了您的权利,请与我们联系,我们将在24小时内进行处理、任何非本站因素导致的法律后果,本站均不负任何责任。

联系QQ:835971066 | 邮箱:835971066#qq.com(#换成@)

Copyright © 2002-2020 脚本教程网 版权所有