News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How i do get logical drive line

Started by goblinC, November 03, 2007, 11:44:47 AM

Previous topic - Next topic

goblinC

Sorry, of my bad english language! I have wishes do getting a valid logical drive line using C or C++. no information about that. function _chdrive, _dos_setdrive be unfitness...

Tedd

This is not a C/C++ forum :P

But, what do you want? (Show an example :wink)
No snowflake in an avalanche feels responsible.

jj2007

Quote from: goblinC on November 03, 2007, 11:44:47 AM
Sorry, of my bad english language! I have wishes do getting a valid logical drive line using C or C++. no information about that. function _chdrive, _dos_setdrive be unfitness...

Check "Detecting Drive Existence" at http://www.pelletiernet.com/helppc/detecting.html
DOS will probably prompt you to insert a disk for each non-active drive...

DrvMap in TOS, SysDriveMap in OS/2.
Win32 offers GetLogicalDrives:



include \masm32\include\masm32rt.inc

.data

Drv dd 0 ; we need only one byte

.code

start: push edi ; save some regs
push esi

invoke GetLogicalDrives
mov edx,eax
push edx ; print uses edx
print chr$("Drives present: ")
pop edx
xor esi,esi

NextD: bt edx,esi ; bit test
jnc NotPresent

mov eax,esi ; counter 0-25
add eax,65 ; 0+65=A
lea edi,Drv
mov [edi],al
push edx ; print uses edx
print edi
print chr$(32)
pop edx

NotPresent: inc esi
cmp esi,26
jb NextD

pop esi
pop edi
invoke ExitProcess,eax
end start


Link with:
\MASM32\BIN\LINK.EXE /SUBSYSTEM:CONSOLE %1.obj

MichaelW

The attachment contains a DOS version of GetLogicalDrives, along with some test code and support procedures.

[attachment deleted by admin]
eschew obfuscation

goblinC

all righ! I m create a quick test to code you owned, and draw attention to those fact--which output result from this programm not quite correctly.
in detail: programm returned all drives included in my system that is ABCDE A(floppy), BCD(hard drive), E(CD-ROM), What i do outputing BCD only a valid hard drive?

i have  interest about asm for the as included in cpp code

Tedd

You need to get the 'type' for each of the valid drives - see if it is floppy/hdd/cdrom/etc..
No snowflake in an avalanche feels responsible.

jj2007

Quote from: Tedd on November 07, 2007, 10:48:33 AM
You need to get the 'type' for each of the valid drives - see if it is floppy/hdd/cdrom/etc..
I could have sworn I saw another text a few minutes ago  :dance:
Goblin, why does it have to be DOS? Windows offers a convenient way to do it, GetDriveType...