调用api函数getfreediskspace的返回值问题

addishu 2000-05-20 10:00:00
你好!
我调用api函数getfreediskspace以求出硬盘的剩余空间,
但此函数在计算2G以上的硬盘时只显示2097MB左右
2G以下正确。请问为什么?怎样解决?

代码如下:

Dim SectorsPerCluster As Long
Dim BytesPerSector As Long
Dim NumOfFreeClusters As Long
Dim TotalNumberOfCluster As Long
Dim FreeDiskSpaces As Long
Dim bool As Boolean
bool = GetDiskFreeSpace(Drive1.Drive, SectorsPerCluster, _
BytesPerSector, NumOfFreeClusters, TotalNumberOfCluster)
If bool = False Then
MsgBox "call error", vbOKOnly
End If

'以BYTE为单位
FreeDiskSpaces = SectorsPerCluster * BytesPerSector * NumOfFreeClusters
'以MB为单位
FreeDiskSpaces = FreeDiskSpaces / 1024000
...全文
110 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Chen_Lin 2000-05-21
  • 打赏
  • 举报
回复
Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias _
"GetDiskFreeSpaceExA" (ByVal lpRootPathName As String, _
lpFreeBytesAvailableToCaller As Any, lpTotalNumberOfBytes _
As Any, lpTotalNumberOfFreeBytes As Any) As Long
-----------在程序中------------
dim a as long
dim b as long
dim c as long
dim d as long
d=GetDiskFreeSpaceEx(Drive1.Drive,a,b,c)
'得到以MB为单位
c=(c/1024)/1024

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧