Get list of all available hardisks? (solved)

Just starting out? Need help? Post your questions and find answers here.
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Get list of all available hardisks? (solved)

Post by Joakim Christiansen »

What is the right method to get all available hardisks on the system?
Last edited by Joakim Christiansen on Sat Apr 21, 2007 2:01 pm, edited 1 time in total.
I like logic, hence I dislike humans but love computers.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Get list of all available hardisks?

Post by PB »

Code: Select all

For a=65 To 90 : a$=Chr(a)+":\"
  If GetDriveType_(a$)=#DRIVE_FIXED
    Debug a$+" is a hard drive"
  EndIf
Next
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

Nice, thank you very much! :D
I like logic, hence I dislike humans but love computers.
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Beep!
Why do you check A: and B: ? You know that these drives are always floppy disks?

Checking 67-90 (C-Z) is enough... And faster, since accessing an existing floppy drive takes 2-5 seconds...
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Code: Select all

For a=65 To 90 : a$=Chr(a)+":\"
  If GetDriveType_(a$)=#DRIVE_FIXED
    Debug a$+" is a hard drive"
  EndIf
Next 
#DRIVE_FIXED. I need that for my CD-rom. It's broken.
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

PLEASE LOOK AT THE MSDN YOURSELF! It wrote:DRIVE_UNKNOWN — The drive type cannot be determined.
DRIVE_NO_ROOT_DIR — The root path is invalid; for example, there is no volume is mounted at the path.
DRIVE_REMOVABLE — The drive has removable media; for example, a floppy drive, thumb drive, or flash card reader.
DRIVE_FIXED — The drive has fixed media; for example, a hard drive or flash 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.
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

:shock: :roll: :wink: :lol: :lol:
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

:?:
PB 4.30

Code: Select all

onErrorGoto(?Fred)
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

AND51 wrote:Why do you check A: and B: ? You know that these drives are always floppy disks?
My B: is a RAM-Drive :twisted:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Correction: Not always, but in most cases.

Ts-Soft, it was YOU who recommended me (and others) not to test for floppy disks: http://www.purebasic.fr/german/viewtopi ... t=&start=0 (Watch the annotation :P
PB 4.30

Code: Select all

onErrorGoto(?Fred)
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

>> YOU who recommended me (and others) not to test for floppy disks
Yes, in some situations under win9x it crashes witout a floppy inserted!
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

So it's better not to test drive A. And with drive B I would be careful, not all ppl have an existing B-drive. In rare cases, ppl have B as a RAM-drive (<= TS-Soft!).
So I'm right, at least a bit. :P
PB 4.30

Code: Select all

onErrorGoto(?Fred)
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

> Why do you check A: and B: ?

It was a quick example by looping through all letters, since drives are listed
by letters. It was just a proof-of-concept, not a finished procedure or such.

> You know that these drives are always floppy disks?

Really? "subst b: e:" points to my e: hard drive on my system.

And what if no floppy is present on a PC? One could probably (I can't test it)
reassign a: with subst to point somewhere else, too -- just as I can with b: as
no b: floppy drive is present on my system.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Dare
Addict
Addict
Posts: 1965
Joined: Mon May 29, 2006 1:01 am
Location: Outback

Post by Dare »

:lol:
Dare2 cut down to size
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

> not a finished procedure or such
Yes, I know. My posting should just be a hint, not a strong recommendation.

> Really? "subst b: e:" points to my e: hard drive on my system.
OK, I didn't thought about this feature. In spite of that, I believe that 95% of all PCs have A:\ and B:\ correctly established (that means eiter a FDD or nothing).

> And what if no floppy is present on a PC?
There will be an error message ("A:\ is a path that is not available...")

> One could probably reassign a: with subst to point somewhere else
I could do it, but I don't. I assume that the same thing will happen like your drive B: - it'll work correctly.
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Post Reply