Page 1 of 1

Detecting disksize

Posted: Thu Jun 24, 2010 11:30 am
by hm@mpsg.net
Does anyone know how to call the kernel32.dll function GetDiskFreeSpaceW
and how to get a value from this function?

Re: Detecting disksize

Posted: Fri Jun 25, 2010 9:24 am
by Auge_Ohr
hm@mpsg.net wrote:Does anyone know how to call the kernel32.dll function GetDiskFreeSpaceW
and how to get a value from this function?
any Reason why not using Xbase++ DiskSpace() ?

Re: Detecting disksize

Posted: Fri Jun 25, 2010 10:40 am
by BruceN
@10.5, 18 dcsay 'Size '
@10.5, 36 dcsay transform(disktotal(CurDrive()),"999,999,999,999,999" )
@10.5, 65 dcsay 'Free '
@10.5, 76 dcsay transform(diskfree(CurDrive()),"999,999,999,999,999" )

I use this to show size and amt free

Hope it helps.....

Re: Detecting disksize

Posted: Fri Jun 25, 2010 11:20 am
by rdonnay
I can't get GetDiskFreeSpaceW() unicode version to work, but GetFreeDiskSpaceA() works fine:
Put this in your source somewhere:

Code: Select all

#include "DLL.CH"
DLLFUNCTION GetDiskFreeSpaceA( a, @b, @c, @d, @e ) USING STDCALL FROM KERNEL32.DLL
Here's how it is used:

Code: Select all

a := 'C:\'
b := 0
c := 0
d := 0
e := 0
GetDiskFreeSpaceA( a, @b, @c, @d, @e )
? b, c, d, e

Re: Detecting disksize

Posted: Mon Jun 28, 2010 5:49 am
by hm@mpsg.net
Thank you Roger

GetDiskFreeSpaceA() works.

Re: Detecting disksize

Posted: Thu Mar 17, 2016 5:08 am
by alepap
I´m using Xbase++ 2.0 Build 2.00.656 and

disktotal()
diskfree()
documented and should be on xbtbase.dll

Does not work.
I found xbtbase1.dll and xbtbase2.dll but no xbtbase.dll

Any idea?

Re: Detecting disksize

Posted: Thu Mar 17, 2016 8:14 am
by rdonnay
There never was an XBTBASE.DLL. They were always XBTBASE1.DLL and XBTBASE2.DLL.

Re: Detecting disksize

Posted: Sun Apr 03, 2016 6:44 pm
by alepap
There is a mistake in xBase++ 2.0 help file.
And disktotal() causes an error

C:\DEV\SEGOVI.obj: error ALK2102: unresolved external symbol DISKTOTAL
ALINK: fatal error ALK4102: 1 external symbols unresolved

Is there another way to get the total size of a disk?


This is the help file information.

DiskTotal()
Determines the total storage capacity of a disk in bytes.

DiskTotal( [<cDrive>] ; // Default: CurDrive()
) --> nTotalStorageCapacity

Description
<cDrive> defaults to the current drive. It can be specified as a drive letter without a colon.

See also
DiskFree()

File info
Dynamic library
XBTBASE.DLL

Re: Detecting disksize

Posted: Sun Apr 03, 2016 7:05 pm
by alepap
#include "DLL.CH"
DLLFUNCTION GetDiskFreeSpaceA( a, @b, @c, @d, @e ) USING STDCALL FROM KERNEL32.DLL

a := 'C:\'
b := 0
c := 0
d := 0
e := 0
GetDiskFreeSpaceA( a, @b, @c, @d, @e )
? b, c, d, e

In this example from Roger Donnay,
b is nb of sectors per cluster
c is nb of bytes per sector
d is nb of free clusters
e is nb of total clusters
total of free bytes is (d x b x c)
total of bytes is (e x b x c)

Re: Detecting disksize

Posted: Tue Jul 19, 2016 7:50 am
by alepap
I found out that XBTBASE.DLL and all functions related to it is part of XBTOOLS III that must be installed separately.

Some interesting functions like
Serial ports
Disk related
Printers

In the help file of xbase++ if you see on the bottom the reference to XBTBASE.DLL it has to do with XBTOOLS III.
You can fine more help on the Xbase++ help under XBTOOLS III Reference.