在vb中如何获得当前磁盘空间?

snowrose 2001-05-08 08:51:00
...全文
164 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
playyuer 2001-05-09
  • 打赏
  • 举报
回复
use API:
《HOWTO: Use the GetDiskFreeSpaceEx() API to Obtain Disk Free Space Amounts》
http://support.microsoft.com/support/kb/articles/q202/4/55.asp
《HOWTO: Find and View the Amount of Free Disk Space on a Drive》
http://support.microsoft.com/support/kb/articles/Q153/0/91.ASP
snowrose 2001-05-08
  • 打赏
  • 举报
回复
我要给分,但我点管理的时候,没有弹出给分的窗口。等会儿再给吧
snowrose 2001-05-08
  • 打赏
  • 举报
回复
thank you:)
playyuer 2001-05-08
  • 打赏
  • 举报
回复
'引用 Microsoft Scripting Runtime
Dim x As New Scripting.FileSystemObject
Dim y As Scripting.Drive
For Each y In x.Drives
Debug.Print y.DriveType
If y.DriveType = Fixed Then
Debug.Print "AvailableSpace: " & y.AvailableSpace / 1024 / 1024 & " MBytes"
Debug.Print "DriveLetter: " & y.DriveLetter
Debug.Print "DriveType: " & y.DriveType
Debug.Print "FileSystem: " & y.FileSystem
Debug.Print "FreeSpace: " & y.FreeSpace / 1024 / 1024 & " MBytes"
Debug.Print "IsReady: " & y.IsReady
Debug.Print "Path: " & y.Path
Debug.Print "RootFolder: " & y.RootFolder
Debug.Print "SerialNumber: " & y.SerialNumber
Debug.Print "ShareName: " & y.ShareName
Debug.Print "TotalSize: " & y.TotalSize / 1024 / 1024 & " MBytes"
Debug.Print "VolumeName: " & y.VolumeName
End If
Next
playyuer 2001-05-08
  • 打赏
  • 举报
回复
'引用 Microsoft Scripting Runtime
Dim x As New Scripting.FileSystemObject
Dim y As Scripting.Drive
For Each y In x.Drives
Debug.Print y.DriveType
If y.DriveType = Fixed Then
Debug.Print y.TotalSize
Debug.Print y.FreeSpace
End If
Next
playyuer 2001-05-08
  • 打赏
  • 举报
回复
'引用 Microsoft Scripting Runtime
Dim x As New Scripting.FileSystemObject
Dim y As Scripting.Drive
For Each y In x.Drives
Debug.Print y.DriveType
If y.DriveType = Fixed Then
y.FreeSpace
End If
Next
playyuer 2001-05-08
  • 打赏
  • 举报
回复
Sub ShowFreeSpace(drvPath)
Dim fs, d, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set d = fs.GetDrive(fs.GetDriveName(drvPath))
s = "Drive " & UCase(drvPath) & " - "
s = s & d.VolumeName & vbCrLf
s = s & "Free Space: " & FormatNumber(d.FreeSpace / 1024, 0)
s = s & " Kbytes"
MsgBox s
End Sub

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧