这篇文章主要为大家展示了“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 & ": - " & 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
以上是“vbs如何判断磁盘类型和检测硬盘剩余空间”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。