QuickBasic program won't detect directories under NT 
Author Message
 QuickBasic program won't detect directories under NT

I haven't tested your code in Windows NT, but may I take this opportunity
to suggest a more reliable way to check for the existence of drives.  Your
method when used on a removable drive will go to the device and expect to
find a disc in it before it will change the path for that drive.  I see you
avoided checking A: and B:, possibly for this reason.  It is obviously not
reasonable to expect that A: and B: will always be the only removable
storage devices in a system.

I wrote a small sample program that makes use of the "PARSE FILENAME INTO
FCB" DOS v1+ function.  This function will enable you to determine the
validity of any drive letter, without activating the drive and expecting to
find a disc in it.  This is powerbasic code, but can with a little
tweaking, be made to work in QuickBASIC:
REM Determine existence of drives
'Declare constants
%FLAGS = 0
%AX = 1
%BX = 2
%CX = 3
%DX = 4
%SI = 5
%DI = 6
%BP = 7
%DS = 8
%ES = 9
%FALSE = 0
%TRUE = 1

'Declare variables and arrays
DIM nCheckDrive AS BYTE
DIM sDriveLetter AS STRING

GOTO Main

FUNCTION IsDriveExistFCB( BYVAL sDrive AS STRING ) PUBLIC AS BYTE
        DIM bRet AS BYTE
   DIM nAL AS BYTE
   DIM sFCB AS STRING * 37
   DIM sFileName AS STRING

   LET bRet = %TRUE
   LET sFileName = sDrive + ":*.*"

   'Use "PARSE FILENAME INTO FCB" function to determine if drive is valid
   REG %AX, &H2900
   REG %DS, STRSEG( sFileName )
   REG %SI, STRPTR( sFileName )
   REG %ES, VARSEG( sFCB )
   REG %DI, VARPTR( sFCB )
   CALL INTERRUPT &H21

   LET nAL = VAL( "&H" + RIGHT$( "000" + HEX$( REG( %AX ) ), 2 ) )
   IF nAL = &HFF THEN LET bRet = %FALSE

   FUNCTION = bRet

END FUNCTION

Main:
CLS

COLOR 7, 0
PRINT "List of drives available:"
FOR nCheckDrive = 1 TO 26
   IF nCheckDrive / 2 = nCheckDrive \ 2 THEN
        PRINT TAB( 41 );
   ELSE
        PRINT TAB( 1 );
   END IF

   LET sDriveLetter = CHR$( nCheckDrive + 64 )
   COLOR 15, 0
        PRINT sDriveLetter + ": ";
   COLOR 7, 0
   SELECT CASE IsDriveExistFCB( sDriveLetter )
        CASE %FALSE
        PRINT "not present";
      CASE %TRUE
        PRINT "exists";
   END SELECT
NEXT nCheckDrive

END

I tested this program on Windows 95 and Windows NT Workstation.  One thing
I did notice was that under Windows 95 it detected the presence of B:
drive, but under Windows NT it did not.  I have no physical B: drive.  I
suspect this is because Windows 95 by default sets up a logical B: drive if
there is no physical B: drive, but Windows NT does not.  This may or may
not be a problem for you.
--
When replying to this message, remove all occurances of the word "dot" from
my e-mail address.



Quote:
> I have an application written in QuickBasic for DOS that works fine under
> Windows 95, DOS, Windows 98, but sometimes not under NT.

> The part of the program that freezes is when I attempt to find what
drives
> are attached to the computer:
<snip>

> Somewhere in the above, the computer freezes.  Like I said, this is only
on NT
> 4.0, and perhaps only when connected to a network or running NTFS.



Mon, 26 Mar 2001 03:00:00 GMT  
 QuickBasic program won't detect directories under NT

Quote:

>I have an application written in QuickBasic for DOS that works fine under
>Windows 95, DOS, Windows 98, but sometimes not under NT.
>The part of the program that freezes is when I attempt to find what drives
>are attached to the computer:
<snip>
> FOR DRIVES% = 68 TO 90
>     Test$ = CHR$(DRIVES%) + ":\"
>     SpecError% = 0
>     ON LOCAL ERROR GOTO FileSpecError
>         CHDIR Test$

<snip>

An alternative high level method is to use NUL, it's usually more
reliable than Chdir -

     Test$ = CHR$(DRIVES%) + ":\NUL"

Quote:
>     SpecError% = 0
>     ON LOCAL ERROR GOTO FileSpecError

     open test$ for input as #1
     close 1

TTfn,
Craig___



Mon, 26 Mar 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Program won't run on NT

2. Program won't work on NT Server

3. Program won't work on NT Server

4. Creating a Program Item in Win 3.1 and Win NT

5. Moving from Win 3.11 to Win NT ?'s

6. simple ftp app developed on win98 won't work on win nt

7. Q: Config of Win '95/Win NT Task Bar via VB4

8. QuickBasic won't run on my Quadra

9. Comm ports and running Quickbasic programs under windows or NT

10. Detecting Novell Logonid in Win NT

11. How to get 'Program Files' directory

12. HELP - Error 50003 - VB5, Win 95, Win 98, Win NT

 

 
Powered by phpBB® Forum Software