Detecting disksize

This forum is for general support of Xbase++
Post Reply
Message
Author
hm@mpsg.net
Posts: 8
Joined: Mon Feb 08, 2010 11:13 am

Detecting disksize

#1 Post by hm@mpsg.net »

Does anyone know how to call the kernel32.dll function GetDiskFreeSpaceW
and how to get a value from this function?

User avatar
Auge_Ohr
Posts: 1405
Joined: Wed Feb 24, 2010 3:44 pm

Re: Detecting disksize

#2 Post 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() ?
greetings by OHR
Jimmy

BruceN
Posts: 280
Joined: Thu Jan 28, 2010 7:46 am
Location: Slidell, LA

Re: Detecting disksize

#3 Post 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.....
There are only 10 kinds of people - those who understand binary and those who don't :)

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Detecting disksize

#4 Post 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
The eXpress train is coming - and it has more cars.

hm@mpsg.net
Posts: 8
Joined: Mon Feb 08, 2010 11:13 am

Re: Detecting disksize

#5 Post by hm@mpsg.net »

Thank you Roger

GetDiskFreeSpaceA() works.

User avatar
alepap
Posts: 94
Joined: Tue Jul 28, 2015 5:15 am

Re: Detecting disksize

#6 Post 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?

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Detecting disksize

#7 Post by rdonnay »

There never was an XBTBASE.DLL. They were always XBTBASE1.DLL and XBTBASE2.DLL.
The eXpress train is coming - and it has more cars.

User avatar
alepap
Posts: 94
Joined: Tue Jul 28, 2015 5:15 am

Re: Detecting disksize

#8 Post 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

User avatar
alepap
Posts: 94
Joined: Tue Jul 28, 2015 5:15 am

Re: Detecting disksize

#9 Post 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)

User avatar
alepap
Posts: 94
Joined: Tue Jul 28, 2015 5:15 am

Re: Detecting disksize

#10 Post 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.

Post Reply