Page 1 of 2
Posted: Tue Mar 26, 2002 3:43 pm
by BackupUser
Restored from previous forum. Originally posted by naw.
Hi,
Does anyone know how to obtain info such as the capacity, used space / free space etc. It would be nice to be able to determine the disk type & manufacturer as well.
I'm writing a M$ auditing tool that passes the data back to a central server, I already have a list of installed software, CPUs, BIOS, Machine Name, address, Windows version, Memory etc - but I cant work out the disk stuff.
Not exciting, I know but useful.
If anyone's interested I'll post the finished work onto the forum (when my code is a little less embarassingly messy
PS Thanks "Mr Skunk" for all your great Registry / INI / System Libs

Posted: Tue Mar 26, 2002 7:58 pm
by BackupUser
Restored from previous forum. Originally posted by Rings.
watch Pauls site at :
http://www.reelmediaproductions.com/pb/
there you can found some examples from me.
Its a long way to the top if you wanna .....CodeGuru
Posted: Wed Mar 27, 2002 11:24 am
by BackupUser
Restored from previous forum. Originally posted by naw.
Hi Rings,
Thanks for the reply, I found your example & ran it on my W2000 laptop,
but the results seemed a bit odd:
-206078976 - lpFreeBytesAvailableToCaller
-1478729728 - lpTotalNumberOfBytes
-206078976 - lpTotalNumberOfFreeBytes
I have an 18.6GB C: Drive with 7.8GB free (according to "My Computer") and
expected to see something like:
18.6*1024*1024*1024 = 19971597926.4 Total Bytes Capacity
7.8*1024*1024*1024 = 8375186227.2 Bytes Free
Am I interpreting the output wrong? Or is there a problem with the source?
- Thanks in advance - Nigel
Posted: Wed Mar 27, 2002 1:30 pm
by BackupUser
Restored from previous forum. Originally posted by tranquil.
Hi Rings,
Thanks for the reply, I found your example & ran it on my W2000 laptop,
but the results seemed a bit odd:
-206078976 - lpFreeBytesAvailableToCaller
-1478729728 - lpTotalNumberOfBytes
-206078976 - lpTotalNumberOfFreeBytes
I have an 18.6GB C: Drive with 7.8GB free (according to "My Computer") and
expected to see something like:
18.6*1024*1024*1024 = 19971597926.4 Total Bytes Capacity
7.8*1024*1024*1024 = 8375186227.2 Bytes Free
Am I interpreting the output wrong? Or is there a problem with the source?
- Thanks in advance - Nigel
You are right, but PureBasic is not able to manage these high values atm. I've got the same problem in our App, so you have to round it up. But as Fred said to me some weeks ago 64 Bit support is planned. Lets wait and see.
Tranquilizer/ Secretly!
Registred PureBasic User
Posted: Wed Mar 27, 2002 2:14 pm
by BackupUser
Restored from previous forum. Originally posted by naw.
You are right, but PureBasic is not able to manage these high values atm. I've got the same problem in our App, so you have to round it up. But as Fred said to me some weeks ago 64 Bit support is planned. Lets wait and see.
Tranquilizer/ Secretly!
Registred PureBasic User
Darn it... that causes me a big problem. I assume Rings' PB Code used API calls or something like that.
Does anyone out there in PB land know if there are equivalents for MegaBytes or GigaBytes, that should be managable in <64 bits.
Thanks Tranquilizer (for the reply)
Posted: Wed Mar 27, 2002 3:53 pm
by BackupUser
Restored from previous forum. Originally posted by Rings.
sorry guys,
you have to use quads (Double-Longs) in the api.
'Pure' only allow Longs, but we have to use DoubleLongs(8 Byte Precision) here.
(the higher bytes are needed and the - sign is from the MSBit)
its a bit trickly, but i will make a solution in the evening.
Edited by - Rings on 27 March 2002 16:25:06
Posted: Wed Mar 27, 2002 10:29 pm
by BackupUser
Restored from previous forum. Originally posted by Danilo.
In a Test with QPC i used DoubleLong (8 bytes) too.
Next week with v3.0 you can use something like this:
Code: Select all
Structure myDLong
value
value2
EndStructure
QueryPerformanceCounter_(test.myDLong)
SetWindowText_(hWnd, StrU(test\value2,#LONG)+StrU(test\value,#LONG))
StrU() is new in v3.0 and is used for UnSigned numbers/variables.
Code: Select all
StrU(number, type)
number = your number / variable
type = #BYTE, #WORD or #LONG
Simply make a Structure "DoubleLong" or so and
declare 2 LONG-Members in it (highWord & lowWord).
cya,
...Danilo
(registered PureBasic user)
Edited by - Danilo on 27 March 2002 22:31:08
Posted: Thu Mar 28, 2002 9:15 am
by BackupUser
Restored from previous forum. Originally posted by Rings.
This is a solution that works, unfortunaly only with Pure 3.0 or higher.
d.s="c:\"
Structure Quad
L1.l
L2.l
EndStructure
FB.Quad;Nimber of free bytes
TB.Quad ;lpTotalNumberOfBytes.l
TFB.Quad ;lpTotalNumberOfFreeBytes.l
Result=GetDiskFreeSpaceEx_(@d, FB, TB, TFB)
sResult.s
sResult=StrU(FB\L1,2) + chr(13) ;" : " +StrU(FB\L2,2)+Chr(13)
sResult=sResult+StrU(TB\L1,2) + Chr(13)
sResult=sResult+StrU(TFB\L1,2) + Chr(13)
If Result=1
MessageRequester("INFO",sResult,0)
EndIf
Its a long way to the top if you wanna .....CodeGuru
Edited by - Rings on 28 March 2002 13:14:04
Posted: Thu Mar 28, 2002 10:34 pm
by BackupUser
Restored from previous forum. Originally posted by Danilo.
Code: Select all
d.s="c:\"
Structure Quad
L1.l
L2.l
EndStructure
Result = GetDiskFreeSpaceEx_(d, FB.Quad, TB.Quad, TFB.Quad)
;FB.Quad = Number of free bytes
;TB.Quad = lpTotalNumberOfBytes.l
;TFB.Quad = lpTotalNumberOfFreeBytes.l
sResult.s = StrU(FB\L2,2) + StrU(FB\L1,2) + Chr(13)
sResult = sResult + StrU(TB\L2,2) + StrU(TB\L1,2) + Chr(13)
sResult = sResult + StrU(TFB\L2,2) + StrU(TFB\L1,2) + Chr(13)
If Result=1
MessageRequester("INFO",sResult,0)
EndIf
cya,
...Danilo
(registered PureBasic user)
Edited by - Danilo on 29 March 2002 01:28:50
Posted: Wed Apr 03, 2002 9:28 am
by BackupUser
Restored from previous forum. Originally posted by naw.
Rings, Danilo, Tranquil,
Thanks for the help - I'll wait for PB3 (unless there's a beta version flying around out there that I can use)
Again - Thanks
- N
Posted: Wed Apr 17, 2002 6:29 pm
by BackupUser
Restored from previous forum. Originally posted by scurrier.
ok I tried the code listed here and it doesn't seem to work correctly
ok for a result i get
this is on a win2k
my c drive has 14.6gigs total
used is 5.32gigs
free is 9.32gigs
1418547200 Free Bytes
2841800704 Total Bytes
1418547200 Total Free Bytes
am i just missing something?
here is the code i used
d.s="c:\"
Structure Quad
L1.l
L2.l
EndStructure
FB.Quad;Nimber of free bytes
TB.Quad ;lpTotalNumberOfBytes.l
TFB.Quad ;lpTotalNumberOfFreeBytes.l
Result=GetDiskFreeSpaceEx_(@d, FB, TB, TFB)
sResult.s
sResult=StrU(FB\L1,2) + chr(13) ;" : " +StrU(FB\L2,2)+Chr(13)
sResult=sResult+StrU(TB\L1,2) + Chr(13)
sResult=sResult+StrU(TFB\L1,2) + Chr(13)
If Result=1
MessageRequester("INFO",sResult,0)
EndIf
Thanks
Sean
Posted: Wed Apr 17, 2002 6:51 pm
by BackupUser
Restored from previous forum. Originally posted by Danilo.
Sorry, scurrier - you cant do it that way.
StrU() cuts the leading 0´s, thats the problem.
Code: Select all
sResult.s = StrU(FB\L2,2) + StrU(FB\L1,2)
This shows you the 2 numbers from the QUAD
variable 1 after another, but the leading 0´s
from L1 are cutted - so the returned String
simply isnt right.
You need to write your own procedure
for converting a 64bit number in a structure
to string.
cya,
...Danilo
(registered PureBasic user)
Posted: Wed Apr 17, 2002 10:35 pm
by BackupUser
Restored from previous forum. Originally posted by freak.
It would be nice to be able to determine the disk type & manufacturer as well.
Well, I don't know about the Size, but about the disk type:
Code: Select all
name.s = "C:\"
type.b = GetDriveType_(@name)
Return Values
DRIVE_UNKNOWN The drive type cannot be determined.
DRIVE_NO_ROOT_DIR The root path is invalid. For example, no volume is mounted at the path.
DRIVE_REMOVABLE The disk can be removed from the drive.
DRIVE_FIXED The disk cannot be removed from the drive.
DRIVE_REMOTE The drive is a remote (network) drive.
DRIVE_CDROM The drive is a CD-ROM drive.
DRIVE_RAMDISK The drive is a RAM disk.
Unfortunately, none of these Constants is known by PB, so here are the Values:
Code: Select all
#DRIVE_UNKNOWN = 0
#DRIVE_ABSENT = 1
#DRIVE_REMOVABLE = 2
#DRIVE_FIXED = 3
#DRIVE_REMOTE = 4
#DRIVE_CDROM = 5
#DRIVE_RAMDISK = 6
About the manufacturer: It seems, that my Win98SE doesn't know the manufacturer of the drives. (In the Registry, they are all named as: manufacturer="GENERIC")
WinXP knows the HDD as a Maxtor drive, so maybe there's a way to get the manufacturer name on XP, but I don't know it. (Maybe your program can search the Registry for a value named "manufacturer")
That's it, hope it helps...
Timo
A debugged program is one for which you have not yet found the conditions that make it fail.
Posted: Thu Apr 18, 2002 10:10 am
by BackupUser
Restored from previous forum. Originally posted by naw.
Hi,
I've (finally) tried with PB3 and the results for the disk sizes are wrong for me too...
Can anyone out there help? Rings, Tranquil, Fred? I dont know the Win API well enough (actually, I dont know it at all) to do this on my own.
Ta - N
BTW - nice API example, Freak - thanks, I'll use that in my "Auditing" tool.
BTW2 - when finished is anyone interested in the code?
Posted: Thu Apr 18, 2002 3:08 pm
by BackupUser
Restored from previous forum. Originally posted by freak.
Hi,
finally, this one works fine. (tested on Win98SE, WinME & WinXP)
Code: Select all
; +++++++++++++ Get Disk Space by Timo Harter ++++++++++++++
drive.s = "C:\"
Structure Quad
L1.l
L2.l
EndStructure
GetDiskFreeSpaceEx_(@drive, FB.Quad, TB.Quad, TFB.Quad)
TB.Quad\L1>>20
TB.Quad\L2>20
TFB.Quad\L2.
That's it,
Timo
A debugged program is one for which you have not yet found the conditions that make it fail.
Edited by - freak on 18 April 2002 16:09:17