Pete's QBASIC Site Forum Index Pete's QBASIC Site
Return to Pete''s QBasic Site
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Drive Information?

 
Post new topic   Reply to topic    Pete's QBASIC Site Forum Index -> Freebasic Questions & Answers
View previous topic :: View next topic  
Author Message
wolfman775



Joined: 10 Aug 2009
Posts: 2

PostPosted: Mon Aug 10, 2009 3:23 am    Post subject: Drive Information? Reply with quote

Hi, Im new here (But not to FreeBASIC), and I was wondering if anybody knew how to get the label and Free/total disk space from a given drive? and possibly the model name?

Thanks in advance.
Back to top
View user's profile Send private message Send e-mail
UWLabs



Joined: 03 Oct 2004
Posts: 11
Location: North Carolina

PostPosted: Mon Aug 10, 2009 8:54 am    Post subject: Use the "shell" command. Reply with quote

Just use shell to access the command.com
Then use simple OS command line commands and save the output; just redirect it to a text file.

For example, to get the name of the harddrive, use the Volume command and pipe it to a text file (then read the text file later).

Code:
SHELL "vol > hdd_labl.txt"

That will shell out to the command prompt run the "vol" command and send the results to a newly created file named hdd_labl.txt which you can open and read later.

For disk size the directory command (dir) has a bunch of options.
the last two lines always output, are the the number of files in the current directory (folder) and the free disk space.

The output will look something like this:

Code:
 Volume in drive C has no label.
 Volume Serial Number is 686B-F0F2

 Directory of C:\

04/13/2009  07:27 AM    <DIR>          7b6bee7553a7b2f5ce2dda1d
01/30/2007  12:24 PM    <DIR>          8c3127ede316849a3e19bd723f
12/08/2006  05:16 PM                 0 CONFIG.SYS
04/15/2009  07:40 AM    <DIR>          Documents and Settings
05/29/2009  09:53 AM    <DIR>          Program Files
04/27/2009  07:51 AM    <DIR>          QBasic
03/11/2009  10:53 AM    <DIR>          QuickBas
08/06/2009  04:30 PM    <DIR>          Temp
08/10/2009  07:48 AM    <DIR>          WINDOWS
               1 File(s)      1,892,240 bytes
               8 Dir(s)  35,276,324,864 bytes free
              29 Dir(s)  35,276,324,864 bytes free


Now good practice is to use specific file extensions for easier recognition by others - so if you forget to 'cleanup' they might know what the file is.
Suggestions:
TXT (text)
LST (list)
TMP (temp)
$$$ (string-temp)
$ (string temp)
QB (qbasic)

Another best practice would be to just "kill" the file after you are done with it, using the BASIC KILL command.

Hope this helps.
Back to top
View user's profile Send private message AIM Address
wolfman775



Joined: 10 Aug 2009
Posts: 2

PostPosted: Tue Aug 11, 2009 10:02 am    Post subject: Reply with quote

Thanks verry much, i didnt know about the vol command.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Pete's QBASIC Site Forum Index -> Freebasic Questions & Answers All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
Protected by Anti-Spam ACP