硬盘空间如何得知?

lwplwp123 2003-10-23 06:22:09
有什么办法可以知道我的C区共有多少空间,用了多还,还有多少?
最好是一个命令,或是一个函数,sql里的函数也可以。
高手请指点一下。
...全文
91 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
lwplwp123 2003-10-24
  • 打赏
  • 举报
回复
高手们,俺想得到远程序服务器上的空间,看来是要再做些努力了。
服务器上有SQL,能不能通过SQL得知,
要不的话俺还得在服务器上运行一个程序。
不过这已要多谢各位了。
晚上给分。
lwplwp123 2003-10-24
  • 打赏
  • 举报
回复
高!
谢!
online 2003-10-24
  • 打赏
  • 举报
回复
如果把与那远程计算机硬盘共享,依次盘符会是h:,k:,l:
sdrive="h:\"即可
如果有driver控件,会自动列出所有的盘符
sDrive = Left$(DrvSelect.Drive, 1)
sDrive = sDrive & ":\"
sharkliang 2003-10-24
  • 打赏
  • 举报
回复
关注
online 2003-10-24
  • 打赏
  • 举报
回复
Option Explicit

' API声明
Private Declare Function GetDiskFreeSpace Lib "kernel32" Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, lpSectorsPerCluster As Long, lpBytesPerSector As Long, lpNumberOfFreeClusters As Long, lpTtoalNumberOfClusters As Long) As Long

Private Sub Form_Load()
GetDriveInfo
End Sub

' 选中一个驱动器时
Private Sub drvSelect_Change()
GetDriveInfo
End Sub

' 获取磁盘剩余空间信息并显示在相应的标签中
Private Function GetDriveInfo()
Dim sDrive As String
Dim lBytes As Long
Dim lMBFree As Double
Dim lMBTotal As Double
Dim lSecPerClust As Long ' 扇区每簇
Dim lBytePerSect As Long ' 字节每扇区
Dim lNumFreeClust As Long ' 空白簇的数目
Dim lTotalNumClust As Long ' 簇的总数

' 获取盘符
sDrive = Left$(DrvSelect.Drive, 1)
sDrive = sDrive & ":\"
' 调用API函数返回剩余空间
lBytes = GetDiskFreeSpace(sDrive, lSecPerClust, lBytePerSect, lNumFreeClust, lTotalNumClust)
' 转换以兆为单位
lMBFree = ((lSecPerClust * lNumFreeClust) / 1024) * lBytePerSect / 1024
lMBTotal = ((lSecPerClust * lTotalNumClust) / 1024) * lBytePerSect / 1024
' 显示信息
lblSecPerClust.Caption = lSecPerClust & " Sectors/Cluster"
lblBytePerSect.Caption = lBytePerSect & " Bytes/Sector"
lblNumFreeClust.Caption = lNumFreeClust & " Free Clusters"
lblTotalNumClust.Caption = lTotalNumClust & " Total Clusters"
lblTotalSpace.Caption = lMBTotal & " MB Total Space"
lblSpaceFree.Caption = lMBFree & " MB Free on Drive " & DrvSelect.Drive
End Function
kmzs 2003-10-23
  • 打赏
  • 举报
回复
不错
whjwsy 2003-10-23
  • 打赏
  • 举报
回复
可用filesystemobject来获取
wxrwan 2003-10-23
  • 打赏
  • 举报
回复
up
TechnoFantasy 2003-10-23
  • 打赏
  • 举报
回复
Private Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias "GetDiskFreeSpaceExA" (ByVal lpRootPathName As String, lpFreeBytesAvailableToCaller As Currency, lpTotalNumberOfBytes As Currency, lpTotalNumberOfFreeBytes As Currency) As Long
Private Sub Form_Load()
Dim r As Long, BytesFreeToCalller As Currency, TotalBytes As Currency
Dim TotalFreeBytes As Currency, TotalBytesUsed As Currency
'the drive to find
Const RootPathName = "C:\"
'get the drive's disk parameters
Call GetDiskFreeSpaceEx(RootPathName, BytesFreeToCalller, TotalBytes, TotalFreeBytes)
'show the results, multiplying the returned
'value by 10000 to adjust for the 4 decimal
'places that the currency data type returns.
Me.AutoRedraw = True
Me.Cls
Me.Print
Me.Print " Total Number Of Bytes:", Format$(TotalBytes * 10000, "###,###,###,##0") & " bytes"
Me.Print " Total Free Bytes:", Format$(TotalFreeBytes * 10000, "###,###,###,##0") & " bytes"
Me.Print " Free Bytes Available:", Format$(BytesFreeToCalller * 10000, "###,###,###,##0") & " bytes"
Me.Print " Total Space Used :", Format$((TotalBytes - TotalFreeBytes) * 10000, "###,###,###,##0") & " bytes"
End Sub
TechnoFantasy 2003-10-23
  • 打赏
  • 举报
回复
API函数GetDiskFreeSpaceEx

7,788

社区成员

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

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