Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / GET DRIVE TOTAL SIZE( Driver Id, Return ) how pass Driver ID to a letter (c: d: etc..)

Author
Message
Neodelito
19
Years of Service
User Offline
Joined: 29th Jul 2005
Location:
Posted: 10th Nov 2010 13:19
I try to join
perform checklist for drives
and
GET DRIVE TOTAL SIZE( Drive ID, Return )

but Driver ID ??? (0,1,2,3,4,5,6)
manual not have info about driver Id
thanks for your help..



Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 10th Nov 2010 18:19
When you use PERFORM CHECKLIST FOR DRIVES it puts only strings in the checklist but the order of the checklist probably represent the drive ID numbers you want.



Neodelito
19
Years of Service
User Offline
Joined: 29th Jul 2005
Location:
Posted: 10th Nov 2010 19:19
thanks Grog Grueslayer but not work..
Only i know is
drive ID 0 = current drive (C: or your base drive)
Drive ID 1,2,3,4 etc..(next drives or cD's..)

But how you know letter of driver id 2 or driver id 3 etc..
enhancement pack is incomplete .. only my opinion..



Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 10th Nov 2010 20:44 Edited at: 10th Nov 2010 20:55
Ah, unfortunately I don't have the Enhancement Pack. I did find this message that talks about the GET DRIVE COUNT() command.

http://forum.thegamecreators.com/?m=forum_view&t=46662&b=1

That may show the last drive ID #. The other commands listed in the help files in the same area as that command may shed some light on which commands you need to use.

Also on the Enhancement Pack page...
http://www.thegamecreators.com/?m=view_product&id=2083

... by Drive Information there's a picture of a program. Could that be an example that came with the Enhancement Pack that you can run to see how the Drive commands work?



Neodelito
19
Years of Service
User Offline
Joined: 29th Jul 2005
Location:
Posted: 11th Nov 2010 02:23
yes you have reason.. i use Enhancement Pack. but in help of Enhancement Pack no exist way to get a letter from driver id..
solution i make a small program in Neobook and pass all vars i need (numbers of drives, size, free, sytem, etc.) to clipboard. yes i know is not god but dark basic no have this basic instruction..
Drive Size, drive free space, drive id etc..
You can parse a simple cmd instruction in a bat file
gethdsise.bat
cd\
dir >hd.txt

but is not my idea i like get this info (disk size) from a native code or get from kernel 32 but i can't do.. ..


i gone cry like a baby..
ha ha ha..

thanks for your help.



Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 13th Nov 2010 05:47 Edited at: 13th Nov 2010 08:32
@Neodelito

Check out:

Get Available Drives

The second message that reads DLL. This uses the win32 API to get the logical drives and to get the drive types.

The ID is represented by whether a particular bit is turned on. Do you understand what I mean by this? A single number is returned that has BITs turned on or off in a number. If the BIT is on, then that bit position represents a drive letter:

0 0 1 0 0 1 1 1 1
- - G - - D C B A

In this code from the link above, you can add a counter to get the Drive Number:



Enjoy your day.
Neodelito
19
Years of Service
User Offline
Joined: 29th Jul 2005
Location:
Posted: 13th Nov 2010 16:28 Edited at: 13th Nov 2010 16:36
thanks Latch.. is very impresive..
But the enhancement pack command is very particular..
this enumerated disk like this..
Driver ID
0 is actual drive
1 next partition *
2 third partition *
3 etc... partition *
4 floppy
5 CD

In the example they use this method
Status counter
1 a (64)
1 b (65)
0 c (66)
1 d (67)
1 e (68)
1 etc... (...)

is not the same


Now how in the world.. you can find a simply letter from Driver ID (using enhancement pack)..

if you see in all languages is very simply use a command like this but in dark basic not exist a god reference..
i experiment using many methods..
only serious i found is your example, and some clue to use kernel32 and GetDiskFreeSpace command, but i cant make this work..

i'm a god modeler, and can make a real goooooood custom model to any can make a simple dll or script to have total disk space, free space using the classic command perform check-list for drives..





Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 13th Nov 2010 17:32
Quote: "Now how in the world.. you can find a simply letter from Driver ID (using enhancement pack)..
"

What is the drive ID ? Is it the serial number of the disk, or just a counting number?

What do you want to do, enter the serial number and get back a letter or enter a counting number (if that is the ID) and get back a letter?

For example:



or



Quote: "...any can make a simple dll or script to have total disk space, free space using the classic command perform check-list for drives..
"

What exactly do you want? Something like:



Enjoy your day.
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 13th Nov 2010 18:07
If you want to use old methods you can use DOS commands to get the free space.

Unfortunately I think there's a bug with EXECUTE FILE that doesn't allow file creation with DOS commands. I tried in both Vista-64 and XP-32 and no DOS command accepted the standard file creation (it outputs all info that would be on the screen to a file instead) ">filename.ext". It still works fine in DOS but not via Darkbasic Pro with EXECUTE FILE.

FSUTIL allows you to see all you want. Go to the command prompt and type "fsutil volume diskfree c:\ >temp.txt" and it'll create temp.txt and have this inside it:


But try to do that with EXECUTE FILE and it doesn't like the ">temp.txt" part so getting the data in a file you can load is impossible till that bug is fixed... if it is a bug.

Neodelito
19
Years of Service
User Offline
Joined: 29th Jul 2005
Location:
Posted: 13th Nov 2010 21:00 Edited at: 13th Nov 2010 21:12
hi latch and thanks for your code..
i like do this..
print TotalSpace("C:\")
print FreeSpace("C:\")

is only and example..

now you cam make this using enhancement pack using this command:
"GET DRIVE TOTAL SIZE
This function allows you to find out the size of the selected hard drive. Setting the "return" parameter determines how the data will be returned. "0" will return bytes, "1" will return megabytes and "2" will return gigabytes
SYNTAX
return integer = GET DRIVE TOTAL SIZE( Drive ID, Return )
"
But where you find the "DRIVE ID"
this is the only one reference i found..
"The parameter "Drive ID" is the index of the drive you want to check."

again 0 is for your local drive, where your app is running
this is not problem, the problem exist if you have various partitions in the disk. example 1 fisical drive and 3 partitions fat32 C:\ d:\ e:\
print GET DRIVE TOTAL SIZE( 0, 1 )
print GET DRIVE TOTAL SIZE( 2, 1 )
print GET DRIVE TOTAL SIZE( 3, 1 )

but if your base dir is D:\ or E:\

And Grog Grueslayer you have reason EXECUTE FILE that doesn't allow file creation with DOS commands. This will be a solution ...

for now i use external programs to get a decent results.. but this is not the idea..

this i try to do..


But not works... error line 17
Run time error - index number illegal at line 17
call dll kernel32,"GetDiskFreeSpaceExA",drive$,ptr,ptr+8,ptr+16



Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 14th Nov 2010 01:34
Quote: "again 0 is for your local drive, where your app is running
this is not problem, the problem exist if you have various partitions in the disk. example 1 fisical drive and 3 partitions fat32 C:\ d:\ e:\
print GET DRIVE TOTAL SIZE( 0, 1 )
print GET DRIVE TOTAL SIZE( 2, 1 )
print GET DRIVE TOTAL SIZE( 3, 1 )"


I see. Well, the partitions are stored as logical drives so their information would read as if they were physical drives. It may not be the case with the enhancement pack - I don't really know, but I think it would be.

Quote: ""The parameter "Drive ID" is the index of the drive you want to check.""

If this is true, then I would guess that the index numbers starting from 1, represent each letter in order. If you use index 0, that means read the current drive for the current directory. It could be anything if you use zero.

To test, try



That will get your drive letters and hopefully the index of each drive. Then try



Use your windows file explorer to compare the sizes. If they match, then you know what the relationship between the indexes and the letters are.

If they match, then your function might look like:





Quote: "But not works... error line 17
Run time error - index number illegal at line 17
call dll kernel32,"GetDiskFreeSpaceExA",drive$,ptr,ptr+8,ptr+16
"


That's strange. It works here - but I have a pretty old computer and that code is for DBC. That code lists the drive letter and gives the memory for the drive.

I don't know what the index is that is illegal. Maybe try changing



to



Enjoy your day.
Neodelito
19
Years of Service
User Offline
Joined: 29th Jul 2005
Location:
Posted: 14th Nov 2010 03:03 Edited at: 14th Nov 2010 03:04
thanks latch.. see this image..





Attachments

Login to view attachments
Neodelito
19
Years of Service
User Offline
Joined: 29th Jul 2005
Location:
Posted: 14th Nov 2010 03:06
here is the dll but i lose the original file an autor.. you know??



Attachments

Login to view attachments
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 14th Nov 2010 05:33
I did figure out a workaround by creating a .bat file and using EXECUTE FILE to run the .bat file. The following code snip makes a .bat file to run FSUTIL to create the file temp.txt, reads the file and displays it.



Neodelito
19
Years of Service
User Offline
Joined: 29th Jul 2005
Location:
Posted: 14th Nov 2010 06:09
yes is an method.. but here you have a better exe than fsutil..
(download)

but the plugin make all works..



i don't remenber the autor..



Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-09-28 22:29:07
Your offset time is: 2024-09-28 22:29:07