GetDiskFreeSpaceEx 函数

简介:

已解决问题

VB如何得到一个文件占用磁盘空间的大小

30  [ 标签:vb磁盘空间大小 ]  易凌风  2010-02-12 23:26
如题

满意答案 好评率:100%

Option Explicit
Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" _
Alias "GetDiskFreeSpaceExA" _
(ByVal lpRootPathName As String, _
lpFreeBytesAvailableToCaller As Currency, _
lpTotalNumberOfBytes As Currency, _
lpTotalNumberOfFreeBytes As Currency) As Long
Dim 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 Sub
Private 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) / 2
End Sub
Private Sub Timer1_Timer()
RootPathName = Drive1.Drive
RootPathName = Mid(RootPathName, 1, 2)
DiskName = StrConv(Left(RootPathName, 1), vbUpperCase)
On Error GoTo errhandler
Dir1.Path = Drive1.Drive
Dim x As String
Label1 = 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 Sub

本文转自9pc9com博客,原文链接:    http://blog.51cto.com/215363/955731     如需转载请自行联系原作者

相关文章
|
4月前
|
Shell PHP
escapeshellarg() 函数
escapeshellarg() 函数
|
5月前
|
存储 自然语言处理 数据处理
有效的函数
有效的函数
33 0
|
算法 编译器
函数(2)
函数(2)
50 0
|
程序员 C语言 C++
函函函函函函函函函函函数——one
函函函函函函函函函函函数——one
104 0
|
Python
什么是函数
什么是函数
113 0
|
Serverless
比值函数
比值函数
232 0
|
SQL
last函数
last函数
148 0
十、详解函数柯里【下】
柯里化是函数的一个高级应用,想要理解它并不简单。因此我一直在思考应该如何更加表达才能让大家理解起来更加容易。 通过上一个章节的学习我们知道,接收函数作为参数的函数,都可以叫做高阶函数。我们常常利用高阶函数来封装一些公共的逻辑。 这一章我们要学习的柯里化,其实就是高阶函数的一种特殊用法。
161 0