Here is some code that will return (I think it does) the total number of
free bytes on a drive. You need to call the ...Ex function and do some
juggling to recompose the value (it might be > than integer maximum). I
would love to get some improvements on this if it is necessary.

One interesting question: the returned value is quite different from what
"properties" of C:\ (windows explorer) gives

'===============================

Type ULARGE_INTEGER
  LowPart As integer
  HighPart As integer
End Type

Declare Function GetDiskFreeSpaceEx Lib "kernel32.dll" Alias
"GetDiskFreeSpaceExA"
(ByVal lpDirectoryName As String, lpFreeBytesAvailableToCaller As
ULARGE_INTEGER ,
        lpTotalNumberOfBytes As ULARGE_INTEGER,
        lpTotalNumberOfFreeBytes As ULARGE_INTEGER ) As integer

declare sub main

dim lpDirectoryName as string
dim lpFreeBytesAvailableToCaller, lpTotalNumberOfBytes,
        lpTotalNumberOfFreeBytes As ULARGE_INTEGER
dim return as string
sub main

lpDirectoryName="c:\data\"
if GetDiskFreeSpaceEx(lpDirectoryName,lpFreeBytesAvailableToCaller,
                lpTotalNumberOfBytes, lpTotalNumberOfFreeBytes)>0 then
        return=str$(-lpTotalNumberOfFreeBytes.lowpart)
        if (lpTotalNumberOfFreeBytes.highpart)>0 then
                return=return+str$(lpTotalNumberOfFreeBytes.highpart)
        end if
        note "Free bytes on : "+lpDirectoryName+chr$(10)+chr$(10)+return
  else
        note "problem with call to GetDiskFreeSpaceEx"
end if

end sub

'===============================

Jacques Paris
e-mail  [EMAIL PROTECTED]
MapInfo/MapBasic support  http://www.paris-pc-gis.com

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Andy
Sent: February 13, 2001 03:25
To: [EMAIL PROTECTED]
Subject: MI-L Help With Windows API





This is driving me up the walls!!!
Basically what I want to do is to use some windows api calls.
They should work fine as they are calling DLL files and Mapbasic =
provides functionality with this.

for example a simple one=20

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

This would work fine, except that Longs are not valid variable types in =
MapInfo I have tried changing them to various other variable types and =
the only one I seem to have success with when I actually call the =
function is Integer. The only problem with integers is that it comes up =
with some weird results.

Can anyone help me?

Your help is much appreciated.
Andy



_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.



_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.

Reply via email to