如何用VB得到硬盘任意一个分区的容量
展开全部
Private Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" _
(ByVal lpRootPathName As String, lpSectorsPerCluster As Long, _
lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As Long) As Long
Private Sub Form_Load()
Dim s As Long, b As Long, f As Long, t As Long
Dim r As Double, a As Double
Dim n As Long
GetDiskFreeSpace "F:", s, b, f, t
r = f
r = r * b * s
a = t
a = a * b * s
'n = a / 1024 / 1024 / 1024
n = a / 1028 / 1028 / 1028
MsgBox "总空间:" & n & "G"
End Sub
(ByVal lpRootPathName As String, lpSectorsPerCluster As Long, _
lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTotalNumberOfClusters As Long) As Long
Private Sub Form_Load()
Dim s As Long, b As Long, f As Long, t As Long
Dim r As Double, a As Double
Dim n As Long
GetDiskFreeSpace "F:", s, b, f, t
r = f
r = r * b * s
a = t
a = a * b * s
'n = a / 1024 / 1024 / 1024
n = a / 1028 / 1028 / 1028
MsgBox "总空间:" & n & "G"
End Sub
展开全部
不用用api函数,直接引用文件系统对象既可(filesystemobject),新建一个drive对象,即可用它的一个属性查看 ,有点忘了,详情请看msdn
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我也是菜鸟一只,不过这些东西可以查一下分区软件。现在有很多分区软件可以选择。下几个软件看一下说明,选择一个好的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询