获得 硬盘的剩余空间 VB
在一个窗口上面加载一个label1控件要在这个控件上面显示当前电脑所有硬盘占用空间和剩余空间,请问代码怎么编写?按你的方法做了,显示说“磁盘未准备好”...
在一个窗口上面加载一个label1 控件 要在这个控件上面显示 当前电脑所有硬盘占用空间和剩余空间,请问代码怎么编写?
按你的方法做了,显示说 “磁盘未准备好” 展开
按你的方法做了,显示说 “磁盘未准备好” 展开
2个回答
展开全部
工程——>引用——>Microsoft scripting runtime
Private Sub Form_Load()
Dim fso As New FileSystemObject
Dim driver As Drive
For Each driver In fso.Drives
Label1.Caption = Label1.Caption & driver.DriveLetter & " FreeSpace" & driver.FreeSpace & " AvailableSpace" & driver.AvailableSpace
Next driver
End Sub
得到的单位是byte如果你想化成GB除以1024^3
Private Sub Form_Load()
Dim fso As New FileSystemObject
Dim driver As Drive
For Each driver In fso.Drives
Label1.Caption = Label1.Caption & driver.DriveLetter & " FreeSpace" & driver.FreeSpace & " AvailableSpace" & driver.AvailableSpace
Next driver
End Sub
得到的单位是byte如果你想化成GB除以1024^3
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Load()
Dim fso As New FileSystemObject
Dim driver As Drive
For Each driver In fso.Drives
If driver.IsReady Then
Label1.Caption = Label1.Caption & driver.DriveLetter & " FreeSpace" & driver.FreeSpace & " AvailableSpace" & driver.AvailableSpace
End If
Next driver
End Sub
其它同楼上
Dim fso As New FileSystemObject
Dim driver As Drive
For Each driver In fso.Drives
If driver.IsReady Then
Label1.Caption = Label1.Caption & driver.DriveLetter & " FreeSpace" & driver.FreeSpace & " AvailableSpace" & driver.AvailableSpace
End If
Next driver
End Sub
其它同楼上
参考资料: wlm_jxj - 高级经理 六级 5-14 11:36
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询