Get list of all available hardisks? (solved)
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
Get list of all available hardisks? (solved)
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.
Re: Get list of all available hardisks?
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.
"PureBasic won't be object oriented, period" - Fred.
- Joakim Christiansen
- Addict
- Posts: 2452
- Joined: Wed Dec 22, 2004 4:12 pm
- Location: Norway
- Contact:
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...
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)
#DRIVE_FIXED. I need that for my CD-rom. It's broken.Code: Select all
For a=65 To 90 : a$=Chr(a)+":\" If GetDriveType_(a$)=#DRIVE_FIXED Debug a$+" is a hard drive" EndIf Next
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)
My B: is a RAM-DriveAND51 wrote:Why do you check A: and B: ? You know that these drives are always floppy disks?

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.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

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
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

PB 4.30
Code: Select all
onErrorGoto(?Fred)
>> YOU who recommended me (and others) not to test for floppy disks
Yes, in some situations under win9x it crashes witout a floppy inserted!
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.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

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.
So I'm right, at least a bit.

PB 4.30
Code: Select all
onErrorGoto(?Fred)
> 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.
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.
"PureBasic won't be object oriented, period" - Fred.
> 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.
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)