1个回答
2013-11-26
展开全部
Option Explicit
Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" _
Alias "GetDiskFreeSpaceExA" _
(ByVal lpRootPathName As String, _
lpFreeBytesAvailableToCaller As Currency, _
lpTotalNumberOfBytes As Currency, _
lpTotalNumberOfFreeBytes As Currency) As LongDim r As Long
Dim BytesFreeToCalller As Currency
Dim TotalBytes As Currency
Dim TotalFreeBytes As Currency
Dim TotalBytesUsed As Currency
Dim RootPathName As String
Dim DiskName As String
Private Sub exit_Click()
Unload Me
End SubPrivate Sub Form_Load()Timer1.Interval = 100 '每0.1秒发生一次Timer事件Drive1.Drive = "c:"checkdiskform.Left = (Screen.Width - checkdiskform.Width) / 2
checkdiskform.Top = (Screen.Height - checkdiskform.Height) / 2End SubPrivate Sub Timer1_Timer()RootPathName = Drive1.Drive
RootPathName = Mid(RootPathName, 1, 2)
DiskName = StrConv(Left(RootPathName, 1), vbUpperCase)On Error GoTo errhandler
Dir1.Path = Drive1.DriveDim x As StringLabel1 = DiskName + "盘的容量信息"
'调用API函数获取容量信息
r = GetDiskFreeSpaceEx(RootPathName, BytesFreeToCalller, TotalBytes, TotalFreeBytes)
'用FORMAT函数输出习惯的数据显示格式
total.Text = Format$(TotalBytes * 10000, "###,###,###,##0")
free.Text = Format$(TotalFreeBytes * 10000, "###,###,###,##0")
used.Text = Format$((TotalBytes - TotalFreeBytes) * 10000, "###,###,###,##0")
Exit Suberrhandler:
frmErr.ShowEnd Sub '一下确认是否插入磁盘
Private Sub cmdCancel_Click()
Unload Me
checkdiskform.Drive1.Drive = "c:"
End SubPrivate Sub Form_Load()
Me.Top = (Screen.Height - checkdiskform.Height) / 2 + (checkdiskform.Height - Me.Height) / 2
Me.Left = (Screen.Width - checkdiskform.Width) / 2 + (checkdiskform.Width - Me.Width) / 2
lblMsg.Caption = "请将磁盘插入驱动器" & UCase(checkdiskform.Drive1.Drive) & "。"If checkdiskform.Drive1.Drive <> "a:" Then
picDrv.Picture = LoadPicture("CDDRIVE.ico")
Else
picDrv.Picture = LoadPicture("35FLOPPY.ico")
End IfEnd Sub
Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" _
Alias "GetDiskFreeSpaceExA" _
(ByVal lpRootPathName As String, _
lpFreeBytesAvailableToCaller As Currency, _
lpTotalNumberOfBytes As Currency, _
lpTotalNumberOfFreeBytes As Currency) As LongDim r As Long
Dim BytesFreeToCalller As Currency
Dim TotalBytes As Currency
Dim TotalFreeBytes As Currency
Dim TotalBytesUsed As Currency
Dim RootPathName As String
Dim DiskName As String
Private Sub exit_Click()
Unload Me
End SubPrivate Sub Form_Load()Timer1.Interval = 100 '每0.1秒发生一次Timer事件Drive1.Drive = "c:"checkdiskform.Left = (Screen.Width - checkdiskform.Width) / 2
checkdiskform.Top = (Screen.Height - checkdiskform.Height) / 2End SubPrivate Sub Timer1_Timer()RootPathName = Drive1.Drive
RootPathName = Mid(RootPathName, 1, 2)
DiskName = StrConv(Left(RootPathName, 1), vbUpperCase)On Error GoTo errhandler
Dir1.Path = Drive1.DriveDim x As StringLabel1 = DiskName + "盘的容量信息"
'调用API函数获取容量信息
r = GetDiskFreeSpaceEx(RootPathName, BytesFreeToCalller, TotalBytes, TotalFreeBytes)
'用FORMAT函数输出习惯的数据显示格式
total.Text = Format$(TotalBytes * 10000, "###,###,###,##0")
free.Text = Format$(TotalFreeBytes * 10000, "###,###,###,##0")
used.Text = Format$((TotalBytes - TotalFreeBytes) * 10000, "###,###,###,##0")
Exit Suberrhandler:
frmErr.ShowEnd Sub '一下确认是否插入磁盘
Private Sub cmdCancel_Click()
Unload Me
checkdiskform.Drive1.Drive = "c:"
End SubPrivate Sub Form_Load()
Me.Top = (Screen.Height - checkdiskform.Height) / 2 + (checkdiskform.Height - Me.Height) / 2
Me.Left = (Screen.Width - checkdiskform.Width) / 2 + (checkdiskform.Width - Me.Width) / 2
lblMsg.Caption = "请将磁盘插入驱动器" & UCase(checkdiskform.Drive1.Drive) & "。"If checkdiskform.Drive1.Drive <> "a:" Then
picDrv.Picture = LoadPicture("CDDRIVE.ico")
Else
picDrv.Picture = LoadPicture("35FLOPPY.ico")
End IfEnd Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询