Author Topic: About getting the useful drives  (Read 4757 times)

untio

  • Regular Member
  • *
  • Posts: 11
About getting the useful drives
« on: July 13, 2012, 04:02:57 AM »
Hi,

First, thanks for reading this post.

I am coding a program for the old msdos to not forget the old coding style. My aplication needs to get the list of useful drives. A, C, etc.

I have achieved the result in the code that I attach, but I do not know if there is a better method or even if my method is wrong.

Has someone got a correct or better way to do this?

Thanks.

jj2007

  • Member
  • *****
  • Posts: 7761
  • Assembler is fun ;-)
    • MasmBasic
Re: About getting the useful drives
« Reply #1 on: July 13, 2012, 06:38:23 AM »
Does your code actually assemble, and if yes, which assembler & linker do you use, and which settings?

I ask because it throws several errors with my assemblers and linkers (and I usually can assemble & link 16-bit apps).

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: About getting the useful drives
« Reply #2 on: July 13, 2012, 10:01:44 AM »
unito,

Since the drives are normally accessed through the OS, which may recognize drives that the BIOS cannot, the “useful” drives are the ones that are recognized by the OS. Also, drive letters are an OS concept, the BIOS uses numbers (0h,1h,... for diskette drives, 80h,81h,... for hard drives). If I were doing this I would use Interrupt 21h Function 4409h. You can simply rotate through the possible drive letters (specified as 1 to 26 in BX) and use the carry flag to determine whether or not the drive is valid.

« Last Edit: July 13, 2012, 06:49:51 PM by MichaelW »
Well Microsoft, here’s another nice mess you’ve gotten us into.

untio

  • Regular Member
  • *
  • Posts: 11
Re: About getting the useful drives
« Reply #3 on: July 13, 2012, 08:52:22 PM »
Hi,

First, thanks for your responses.

When I use function 4409h, I receive the same response from drive a than from drive b, but the system does not have any drive b.

When I use edit.exe to open a file, it lists the disk drives that are attached to the system. It does not list drive b, because there is not any drive b.

I attach the full code. It compiles with tasm v 3.2

Thanks for your attention.

REEDITED. Now I have attached the code.

Gunther

  • Member
  • *****
  • Posts: 3518
  • Forgive your enemies, but never forget their names
Re: About getting the useful drives
« Reply #4 on: July 13, 2012, 10:55:35 PM »
My active DOS times are a bit far away. If I remember it right, there was the following drive naming:

Drive A: the 3.5'' disk
Drive B: the old 5.25'' disk etc.

But I'm not 100% sure.

Gunther
Get your facts first, and then you can distort them.

FORTRANS

  • Member
  • ****
  • Posts: 946
Re: About getting the useful drives
« Reply #5 on: July 14, 2012, 12:53:05 AM »
Hi,

   IIRC, DOS systems with two floppy drives named
them A: and B:.  If there was only one drive, it named
it A: and used B: too allow copying fron one diskette
to another.  It prompts you to swap diskettes when it
fills its buffers.  So a B: drive can show up even if it
does not really happen to be there in the real world.

Regards,

Steve N.

untio

  • Regular Member
  • *
  • Posts: 11
Re: About getting the useful drives
« Reply #6 on: July 14, 2012, 01:46:29 AM »
Hi,

Thanks a lot for your answers. I thinked that it could be an standard way to handle this.

Doing it like I coded it seems to work.

Cheers.

MichaelW

  • Global Moderator
  • Member
  • *****
  • Posts: 1209
Re: About getting the useful drives
« Reply #7 on: July 14, 2012, 01:55:07 AM »
As I stated, the OS may recognize drives that the BIOS cannot. From the Microsoft MS-DOS 5.0 Programmer’s Reference:
Quote
MS-DOS usually reserves the first two logical drives for floppy disk drives. On Computers that have only one floppy drive, the second logical drive is often treated as an alias for the first. In this case Is Drive Remote (Interrupt 21h, Function 4409h) specifies the first and second drives as valid drives, even though they share the same physical drive. A program can determine whether two or more logical drives share physical drive by using Get Logical Drive Map (Interrupt 21h, Function 440Eh)…

Other examples of “useful” drives that the BIOS Interrupt 13h functions cannot recognize would be network drives, drives created with SUBST, and drives provided by special device drivers (CD-ROM drives for example).

For Windows 2000 and XP, running on a system with one floppy drive Is Drive Remote does not show drive B as valid.
Well Microsoft, here’s another nice mess you’ve gotten us into.

untio

  • Regular Member
  • *
  • Posts: 11
Re: About getting the useful drives
« Reply #8 on: July 14, 2012, 03:14:23 AM »
Hi,

Thanks once more.

In my code, first I test the kind of floppy drive of units a and b. In my system (a virtual box machine running msdos 5 and windows 3.1) this detects that unit b does not exist.

To manage the other possible drives, I change the default drive to each of them and I get the default drive, if both are the same then the unit exists. With this silly solution I detect that unit e does not exist, as it happens.

Cheers.

untio

  • Regular Member
  • *
  • Posts: 11
Re: About getting the useful drives
« Reply #9 on: November 12, 2012, 12:26:49 AM »
Hi,

You were right. Using your method the code works greatly. And, in msdos, when I open edit.exe searching for a file there is a drive a: and a drive b: even if drive b: does not exist.

I attach my new code.

Thanks a lot and forgive my mistakes.