博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
调用API函数得到磁盘上剩余空间的值 (转)
阅读量:2502 次
发布时间:2019-05-11

本文共 1254 字,大约阅读时间需要 4 分钟。

调用API函数得到磁盘上剩余空间的值 (转)[@more@]

 

 

得到上剩余空间的值

最直接的方法是调用API函数 GetDiskFreeSpace,函数声明如下:

声明:

Declare Function GetDiskFreeSpace Lib "kernel32" Alias 
"GetDiskFreeSpaceA" (ByVal lpPathName As String, lpSectorsPerCluster 
As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, 
lpTtoalNumberOfClusters As Long) As Long
使用:
Private Sub Form_Load()
'Man 2001
'URL: http://goodvbman.yeah
'E-: coolde@21cn.com
Dim Sectors as Long,Bytes as Long,FreeC as Long, TotalC as Long,Total as Long,Freeb as Long
'Retrieve information about the C:
GetDiskFreeSpace "C:", Sectors, Bytes, Freec, Totalc
'Set graphic mode to persistent
Me.AutoRedraw = True
'Print the information to the form
Me.Print " Path: C:"
Me.Print " Sectors per Cluster:" + Str$(Sector)
Me.Print " Bytes per sector:" + Str$(Bytes)
Me.Print " Number Of Free Clusters:" + Str$(Freec)
Me.Print " Total Number Of Clusters:" + Str$(Totalc)
Total = rTotalc& * rSector& * rBytes&
Me.Print " Total number of bytes in path:" + Str$(Total)
Freeb = rFreec& * rSector& * rBytes&
Me.Print " Free bytes:" + Str$(Freeb)
End sub

计算规则:磁盘上剩余空间(字节)=磁道(Sector) *剩余扇区 *每扇区的字节数

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10748419/viewspace-1007455/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/10748419/viewspace-1007455/

你可能感兴趣的文章
设计模式06_原型
查看>>
设计模式07_建造者
查看>>
设计模式08_适配器
查看>>
设计模式09_代理模式
查看>>
设计模式10_桥接
查看>>
设计模式11_装饰器
查看>>
克罗谈投资策略02_赢家和输家
查看>>
通向财务自由之路02_成功的决定因素:你
查看>>
中低频量化交易策略研发06_推进的择时策略
查看>>
史丹·温斯坦称傲牛熊市的秘密
查看>>
TB创建公式应用dll失败 请检查用户权限,终极解决方案
查看>>
python绘制k线图(蜡烛图)报错 No module named 'matplotlib.finance
查看>>
talib均线大全
查看>>
期货市场技术分析07_摆动指数和相反意见理论
查看>>
满屏的指标?删了吧,手把手教你裸 K 交易!
查看>>
不吹不黑 | 聊聊为什么要用99%精度的数据回测
查看>>
高频交易的几种策略
查看>>
量化策略回测TRIXKDJ
查看>>
量化策略回测唐安奇通道
查看>>
CTA策略如何过滤部分震荡行情?
查看>>