home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1994 #1
/
monster.zip
/
monster
/
PROG_BAS
/
DISKSTF.ZIP
/
DISKSTUF.TXT
< prev
next >
Wrap
Text File
|
1994-02-09
|
4KB
|
115 lines
DISKSTUF.DLL
This DLL is provided as a service to all VB users who may find it
useful. If you choose to use this DLL then you do so *AT YOUR OWN
RISK*, however, I have been using it in all my VB3 apps with success.
There are two functions in this DLL that you can use with VBWIN.
I will explain each separately:
*******************GetDriveSpace*************************************
1. This function returns the free disk space of any valid drive.
It must be supplied two parameters, an integer (drive number) and a
long variable used to return the free disk space. Place the dll in
the Windows system directory. The declaration is as follows (type
full declaration on one line):
Declare Function GetDriveSpace% Lib "diskstuf.dll" Alias "#1"
(ByVal drive%, free&)
Drive parameter:
drive% = 0 'Current Drive
drive% = 1 'Drive A:
drive% = 2 'Drive B:
drive% = 3 'Drive C:
...etc
Notice that there is no 'ByVal' used with free&.
If the function is successful it will return True, otherwise False
Here is an example of calling the DLL:
Sub cmdDriveSpace_ Click()
Dim drive%
Dim free&
Dim ok%
drive% = 0 'current drive
ok% = GetDriveSpace(drive%, free&)
If ok% then
...code to use value returned by free&
Else
...what to do if function not successful
End If
End Sub
What you must take into consideration when using 'free&' is that the
DLL returns an unsigned long, which is not available within VB.
Therefore, if the free disk space is larger than the VB maximum size
for a long (2,147,483,647) it will return a negative value. For example,
this code seems to check for free disk space over 100000:
If free > 100000 Then
...etc
End If
This code will take into consideration the negative values:
If free < 0 And free > 100000 Then
...etc
End If
*******************************GetVolInfo*******************************
2. This function returns the VOLSTRUCT info for any valid drive.
It must be supplied two parameters, an integer (drive number) and a
user defined type to hold the VOLSTRUCT information.
This function calls an undocumented DOS FCB function. This function is
valid for DOS version 4.0 to 6.2. Before using this function with future
versions of DOS or Windows it is suggested you test it first.
Place the dll in the Windows system directory. The declaration is as follows
(type full declaration on one line):
Type VOLSTRUCT
vlevel As Integer 'unknown as to its use
vserial As Long 'returns drive serial number
vlabel As String * 11 'returns drive volume label
vfat As String * 8 'returns drive FAT bit value
End Type
Declare Function GetVolInfo% Lib "diskstuf.dll" Alias "#3"
(ByVal drive%, vinfo As VOLSTRUCT)
Drive parameter:
drive% = 0 'Current Drive
drive% = 1 'Drive A:
drive% = 2 'Drive B:
drive% = 3 'Drive C:
...etc
If the function is successful it will return True, otherwise False.
Ensure you check the return value of the function before you act on
the results
Here is an example of calling the DLL:
Sub cmdVolInfo_ Click()
Dim drive%
Dim volinfo As VOLSTRUCT
Dim ok%
drive% = 1 'Drive A:
ok% = GetDriveSpace(drive%, volinfo)
If ok% then
...code to use volinfo, i.e
myVolLabel$ = volinfo.vlabel
myVolSerial$ = Hex$(volinfo.vserial)
Else
...what to do if function not successful
End If
End Sub
This DLL is submitted by Douglas Marquardt, 72253,3113