Call the API function to get the value of the remaining space on the disk

zhaozj2021-02-11  244

Call the API function to get the value of the remaining space on the disk

The most direct way is to call the API function GetDiskFreeSpace, the function declaration as follows: Declaration: 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 Usage: Private Sub Form_Load () 'VB Man 2001'URL: http://goodvbman.yeah.net'e-mail: Colde@21cn.comdim 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 persistentMe.AutoRedraw = True'Print the information to the formMe.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

Calculation rules: Remaining space on disk (byte) = track (sector) * Remaining sector * The number of bytes per sector

转载请注明原文地址:https://www.9cbs.com/read-4864.html

New Post(0)