注册 | 登录
收藏 | 帮助
热门文章
编辑推荐
相关文章  
网友经验:手工剿灭木马“advapi
WAP手机网站入侵实例 不让上传我
Linux做WAP网关
LDAP应用概述与qmail+LDAP安装配
为imail和Mdaemon设计Webmail---
imail和Mdaemon设计Webmail-发送
IMail操作指南(13)-IMAP4 Serve
IMail操作指南(14)-LDAP Server
用ASP获取MDaemon域名列表
用ASP检查MDaemon系统管理员登录
您现在的位置: 顶尖设计 >> IT学院 >> 编程开发 >> VB >> 文章正文
调用API函数得到磁盘上剩余空间的值
作者:shawls  来源:CSDN  点击:  更新:2006-12-19
简介:

 

 

调用API函数得到磁盘上剩余空间的值


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

声明:

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()
'VB Man 2001
'URL: http://goodvbman.yeah.net
'E-Mail: 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) *剩余扇区 *每扇区的字节数






  • 上一篇文章:
  • 下一篇文章:
  • 分享此文:该页面添加到 Mister Wong 添加到雅虎Yahoo!收藏 Add to:Del.icio.us Post to Furl Digg this 添加到Google书签 reddit spurl blogmarks 365Key 评论  收藏  分享  打印
     我来说两句
    姓名:       验证码:   
    主页: 
    评分: 1分 2分 3分 4分 5分
    本频道近期热评文章:
      关于我们 | 联系我们 | 站点地图 | 广告投放 | 友情链接 | 在线留言 | 版权申明
    版权所有 © 2004-2007 顶尖设计(bobd.cn)
    未经授权禁止转载,摘编,复制本站内容或建立镜像. 沪ICP备07504942号 
    网络110
    报警服务