home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Programmer'…arterly (Limited Edition) / Visual_Basic_Programmers_Journal_VB-CD_Quarterly_Limited_Edition_1995.iso / code / ch29code / diskspce.frm (.txt) < prev    next >
Visual Basic Form  |  1995-08-02  |  2KB  |  57 lines

  1. VERSION 4.00
  2. Begin VB.Form frmDiskSpace 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   675
  5.    ClientLeft      =   1140
  6.    ClientTop       =   1515
  7.    ClientWidth     =   3060
  8.    Height          =   1080
  9.    Left            =   1080
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   675
  12.    ScaleWidth      =   3060
  13.    Top             =   1170
  14.    Width           =   3180
  15.    Begin VB.CommandButton Command1 
  16.       Caption         =   "Get Free DiskSpace"
  17.       Height          =   435
  18.       Left            =   105
  19.       TabIndex        =   0
  20.       Top             =   105
  21.       Width           =   2850
  22.    End
  23. Attribute VB_Name = "frmDiskSpace"
  24. Attribute VB_Creatable = False
  25. Attribute VB_Exposed = False
  26. Option Explicit
  27. #If Win32 Then
  28. Private Declare Function DiskSpaceFree Lib "STKIT432.DLL" Alias _
  29.     "DISKSPACEFREE" () As Long
  30. #Else
  31. Private Declare Function DiskSpaceFree Lib "STKIT416.DLL" () _
  32.     As Long
  33. #End If
  34. '*************************************************************
  35. ' Get the disk space free for a specific drive
  36. '*************************************************************
  37. Public Function GetDiskSpaceFree(sDrive As String)
  38. Dim res As Long
  39.     On Error Resume Next
  40.     '*********************************************************
  41.     ' Change to the drive that you wish to check.
  42.     '*********************************************************
  43.     ChDrive sDrive
  44.     res = DiskSpaceFree()
  45.     '*********************************************************
  46.     ' If STKIT4*.DLL or drive can't be found, then return -1.
  47.     '*********************************************************
  48.     GetDiskSpaceFree = IIf(Err, -1, Format(res, _
  49.                            "###,###,###,##0"))
  50. End Function
  51. '*************************************************************
  52. ' Get the disk space free for the current drive
  53. '*************************************************************
  54. Private Sub Command1_Click()
  55.     Caption = GetDiskSpaceFree(Left(CurDir, 1))
  56. End Sub
  57.