VB如何得到磁盘使用率?
2个回答
2014-08-30
展开全部
'在form中添加label控件4个,textbox控件4个,Drivelistbox控件1个
Option Explicit
Private Declare Function SHGetDiskFreeSpace Lib "shell32" Alias "SHGetDiskFreeSpaceA" (ByVal pszVolume As String, pqwFreeCaller As Currency, pqwTot As Currency, pqwFree As Currency) As Long
Dim mydisk As String
Dim diskfree As Currency, disktotal As Currency, Free As Currency
Private Sub Drive1_Change()
mydisk = Drive1.Drive & "\"
SHGetDiskFreeSpace mydisk, diskfree, disktotal, Free
Text1 = Format(disktotal / 104857, "0.00")
Text2 = Format((disktotal - diskfree) / 104857, "0.00")
Text3 = Format(diskfree / 104857, "0.00")
Text4 = Format(100 * (disktotal - diskfree) / disktotal, "0.00")
If Text4.Text < 0.2 Then MsgBox ("您的C盘磁盘空间不足,请清除无用文件!!")
End Sub
Private Sub Form_Load()
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
Label1.Caption = "全部磁盘容量为: GB"
Label2.Caption = "磁盘已用空间为: GB"
Label3.Caption = "磁盘剩余空间为: GB"
Label4.Caption = "磁盘利用情况%: %"
Drive1.Drive = "C:"
End Sub
Option Explicit
Private Declare Function SHGetDiskFreeSpace Lib "shell32" Alias "SHGetDiskFreeSpaceA" (ByVal pszVolume As String, pqwFreeCaller As Currency, pqwTot As Currency, pqwFree As Currency) As Long
Dim mydisk As String
Dim diskfree As Currency, disktotal As Currency, Free As Currency
Private Sub Drive1_Change()
mydisk = Drive1.Drive & "\"
SHGetDiskFreeSpace mydisk, diskfree, disktotal, Free
Text1 = Format(disktotal / 104857, "0.00")
Text2 = Format((disktotal - diskfree) / 104857, "0.00")
Text3 = Format(diskfree / 104857, "0.00")
Text4 = Format(100 * (disktotal - diskfree) / disktotal, "0.00")
If Text4.Text < 0.2 Then MsgBox ("您的C盘磁盘空间不足,请清除无用文件!!")
End Sub
Private Sub Form_Load()
Me.Left = (Screen.Width - Me.Width) / 2
Me.Top = (Screen.Height - Me.Height) / 2
Label1.Caption = "全部磁盘容量为: GB"
Label2.Caption = "磁盘已用空间为: GB"
Label3.Caption = "磁盘剩余空间为: GB"
Label4.Caption = "磁盘利用情况%: %"
Drive1.Drive = "C:"
End Sub
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
vb什么版本?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询