# Of Disk Drives 1/2

 BBS: Inland Empire Archive
Date: 04-17-92 (22:28)             Number: 190
From: LOGAN ASHBY                  Refer#: NONE
  To: DICK DENNISON                 Recvd: NO  
Subj: # Of Disk Drives 1/2           Conf: (2) Quik_Bas
Dick,

In a msg of <15 Apr 92>, Dick Dennison writes to Logan Ashby:

 DD > Do you have code to differentiate between a logical and a physical
 DD > drive?  Please post if so.

Well, kinda.

 '|--------------------------- TRUNAME.BAS ---------------------------|
 '|  Checks for physical and logical drives on a system, returns      |
 '|  the truename for SUBSTed and JOINed drives                       |
 '|  Logan Ashby - 04/17/92 - Public Domain and worth every penny! B-)|
 '|
-|
'$INCLUDE: 'QBX.BI' DEFINT A-Z DECLARE FUNCTION IsRemoveable%(DrvNum%) DECLARE SUB TrueName(DrvNum%, LogicalDrv%, RemappedTo$) CONST FALSE = 0 CONST TRUE = -1 DIM SHARED RegsX AS RegTypeX COMMON SHARED DriveLetter$, Null$ DriveLetter$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" Null$ = CHR$(0) CLS RegsX.ax = &H1900 '| Get starting crnt drive CALL InterruptX(&H21, RegsX, RegsX) CurDrv% = RegsX.ax NumDrvs% = 0 FOR i% = 0 TO 25 RegsX.ax = &HE00 '| Set CurrentDrive RegsX.dx = i% CALL InterruptX(&H21, RegsX, RegsX) RegsX.ax = &H1900 '| Did it take? CALL InterruptX(&H21, RegsX, RegsX) IF ((RegsX.ax AND &HFF) = i%) THEN NumDrvs% = NumDrvs% + 1 '| Yes, add it to the count ELSE MID$(DriveLetter$, (i% + 1)) = " " END IF NEXT i% RegsX.ax = &HE00 '| Restore original Drive RegsX.dx = CurDrv% CALL InterruptX(&H21, RegsX, RegsX) PRINT " Number of Disk Drives:"; NumDrvs% PRINT "Valid Drive Letters are: "; DriveLetter$ '|--------------------------------------------------------- '| OK, we got the valid drive letters, lets see which ones '| are physical and which are logical. '|--------------------------------------------------------- FOR i% = 0 TO 25 DriveLtr$ = MID$(DriveLetter$, (i% + 1), 1) IF (DriveLtr$ <> " ") THEN LOCATE 3, 1 PRINT "Drive "; DriveLtr$; " is:" '|-------------------------------------------------- '| Get the actual true name of the drive letter, '| using Int &H21, Function &H60. Available since '| DOS 3.0, but not documented until 5.0 '|-------------------------------------------------- CALL TrueName(i%, Logical%, RemappedTo$) IF (Logical%) THEN '!!!!!!! Next two lines should be one. !!!!!!! PRINT " Logical Drive : "; RemappedTo$; _ " " ELSE Print " Physical Drive " END IF PRINT PRINT "Strike Any Key to Continue "; DO LOOP UNTIL (LEN(INKEY$)) END IF NEXT i% END - - - - - - - - continued next message - - - - - - - - - - - - - --- GoldED 2.40 * Origin: Lurker's Lounging Point (1:398/1.2)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET