home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #1 / monster.zip / monster / PROG_BAS / DISKSTF.ZIP / DISKSTUF.TXT < prev    next >
Text File  |  1994-02-09  |  4KB  |  115 lines

  1. DISKSTUF.DLL
  2.  
  3. This DLL is provided as a service to all VB users who may find it
  4. useful.  If you choose to use this DLL then you do so *AT YOUR OWN
  5. RISK*, however, I have been using it in all my VB3 apps with success.
  6.  
  7. There are two functions in this DLL that you can use with VBWIN. 
  8. I will explain each separately:
  9.  
  10. *******************GetDriveSpace*************************************
  11.  
  12. 1.  This function returns the free disk space of any valid drive.
  13. It must be supplied two parameters, an integer (drive number) and a 
  14. long variable used to return the free disk space.  Place the dll in
  15. the Windows system directory.  The declaration is as follows (type 
  16. full declaration on one line):
  17.  
  18. Declare Function GetDriveSpace% Lib "diskstuf.dll" Alias "#1" 
  19.   (ByVal drive%, free&)
  20.  
  21. Drive parameter:
  22.   drive% =  0       'Current Drive
  23.   drive% =  1       'Drive A:
  24.   drive% =  2       'Drive B:
  25.   drive% =  3       'Drive C:
  26.   ...etc
  27.  
  28. Notice that there is no 'ByVal' used with free&.
  29.  
  30. If the function is successful it will return True, otherwise False
  31.  
  32. Here is an example of calling the DLL:
  33.  
  34. Sub cmdDriveSpace_ Click()
  35.   Dim drive%
  36.   Dim free&
  37.   Dim ok%
  38.   drive% = 0    'current drive
  39.   ok% = GetDriveSpace(drive%, free&)
  40.   If ok% then
  41.     ...code to use value returned by free&
  42.   Else
  43.     ...what to do if function not successful
  44.   End If
  45. End Sub 
  46.  
  47. What you must take into consideration when using 'free&' is that the 
  48. DLL returns an unsigned long, which is not available within VB.  
  49. Therefore, if the free disk space is larger than the VB maximum size
  50. for a long (2,147,483,647) it will return a negative value.  For example,
  51. this code seems to check for free disk space over 100000:
  52.  
  53.     If free > 100000 Then
  54.     ...etc
  55.     End If
  56.  
  57. This code will take into consideration the negative values:
  58.  
  59.     If free < 0 And free > 100000 Then
  60.         ...etc
  61.     End If
  62.  
  63. *******************************GetVolInfo*******************************
  64.  
  65. 2.  This function returns the VOLSTRUCT info for any valid drive.
  66. It must be supplied two parameters, an integer (drive number) and a 
  67. user defined type to hold the VOLSTRUCT information.  
  68.  
  69. This function calls an undocumented DOS FCB function.  This function is
  70. valid for DOS version 4.0 to 6.2.  Before using this function with future
  71. versions of DOS or Windows it is suggested you test it first.
  72.  
  73. Place the dll in the Windows system directory.  The declaration is as follows 
  74. (type full declaration on one line):
  75.  
  76. Type VOLSTRUCT
  77.   vlevel As Integer         'unknown as to its use
  78.   vserial As Long           'returns drive serial number
  79.   vlabel As String * 11     'returns drive volume label
  80.   vfat As String * 8        'returns drive FAT bit value 
  81. End Type
  82.  
  83. Declare Function GetVolInfo% Lib "diskstuf.dll" Alias "#3" 
  84.   (ByVal drive%, vinfo As VOLSTRUCT)
  85.  
  86. Drive parameter:
  87.   drive% =  0       'Current Drive
  88.   drive% =  1       'Drive A:
  89.   drive% =  2       'Drive B:
  90.   drive% =  3       'Drive C:
  91.   ...etc
  92.  
  93. If the function is successful it will return True, otherwise False.  
  94. Ensure you check the return value of the function before you act on
  95. the results
  96.  
  97. Here is an example of calling the DLL:
  98.  
  99. Sub cmdVolInfo_ Click()
  100.   Dim drive%
  101.   Dim volinfo As VOLSTRUCT
  102.   Dim ok%
  103.   drive% = 1    'Drive A:
  104.   ok% = GetDriveSpace(drive%, volinfo)
  105.   If ok% then
  106.     ...code to use volinfo, i.e
  107.     myVolLabel$ = volinfo.vlabel
  108.     myVolSerial$ = Hex$(volinfo.vserial)
  109.   Else
  110.     ...what to do if function not successful
  111.   End If
  112. End Sub 
  113.  
  114. This DLL is submitted by Douglas Marquardt, 72253,3113
  115.