Microsoft KB Archive/45423

= Basic's CALL INTERRUPT Can Get/Set File Attributes in MS-DOS =

Article ID: 45423

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b

-



This article was previously published under Q45423



SUMMARY
The program below demonstrates how to use Basic's CALL INTERRUPT statement to get and set the attributes of files in MS-DOS.



MORE INFORMATION
The program below uses MS-DOS interrupt 21 hex with function 43 hex (67 decimal) to get or set file attributes.

FILEATT.BAS
DECLARE SUB showattributes (status AS INTEGER) REM $INCLUDE: 'QB.BI' ' For QBX.EXE and BC.EXE in Basic PDS 7.00 use the include file 'QBX.BI' ' This .BI file defines the RegTypex data TYPE.

CONST SETREADONLY = &H1 CONST SETHIDDEN = &H2 CONST SETSYSTEM = &H4 CONST SETARCHIVE = &H32 DIM inregs AS RegTypex, outregs AS RegTypex CLS INPUT &quot;Enter File Name (with full pathname): &quot;; filename$

' add CHR$(0) to make an ASCIIZ (null-terminated) string: filename$ = filename$ + CHR$(0)

inregs.ax = &H4300                   ' get file attributes inregs.dx = SADD(filename$)  ' Offset of ASCIIZ filename. inregs.ds = VARSEG(filename$) ' Segment of ASCIIZ filename. ' For BC.EXE and QBX.EXE from Basic PDS 7.00/7.10, substitute the ' above line with the following line: '  inregs.ds = SSEG(filename$)

CALL INTERRUPTX(&H21, inregs, outregs) showattributes outregs.cx

' set hidden attribute inregs.ax = &H4301                   ' set file attributes

' mask off the volume labels directory and reserved bits setstatus% = outregs.cx AND &H27

setstatus% = setstatus% OR SETHIDDEN ' set hidden attribute bit inregs.cx = setstatus% CALL INTERRUPTX(&H21, inregs, outregs) showattributes outregs.cx

SUB showattributes (status AS INTEGER) PRINT PRINT &quot;File Attributes Set&quot; PRINT &quot;---&quot; IF status% AND SETREADONLY THEN PRINT &quot;read-only&quot; IF status% AND SETHIDDEN THEN PRINT &quot;hidden&quot; IF status% AND SETSYSTEM THEN PRINT &quot;system&quot; IF status% AND 8 THEN PRINT &quot;volume label&quot; IF status% AND 16 THEN PRINT &quot;directory&quot; IF status% AND SETARCHIVE THEN PRINT &quot;archive&quot; END SUB

Additional query words: QuickBas BasicCom

Keywords: KB45423

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.