Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB - Get Free Disk Space

Status
Not open for further replies.

saw15

Technical User
Jan 24, 2001
468
US
Good day ..

Wondering if there was a way (with VB) to give a remote machine a command (sort of like PING ) that would read the amount of free disk space on the remote machine using the port, and then submit it back to the VB application?

Sorry if this is vague.

Any help or pointers in the right direction would be a great help.

 
'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Insert the following code to your module:

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

'Insert the following code to your form:

Private Sub Form_Load()
'Replace the 'c:\' below with the drive you want to get his information
result = GetDiskFreeSpace("c:\", lspc, lbps, lnofc, ltnoc)
If result = 0 Then MsgBox "There was An Error!"
MyCapacity = lspc * lbps * ltnoc
MyFree = lspc * lbps * lnofc
MyUsed = MyCapacity - MyFree
MsgBox "Capacity: " & MyCapacity & " Bytes"
MsgBox "Free: " & MyFree & " Bytes"
MsgBox "Used: " & MyUsed & " Bytes"
End Sub

Eric De Decker
vbg.be@vbgroup.nl

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top