Microsoft KB Archive/40887

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 17:56, 18 July 2020 by 3155ffGd (talk | contribs) (importing KB archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


Macintosh QuickBASIC Program to Hide/Unhide File in Finder

Article ID: 40887

Article Last Modified on 11/21/2006

This article was previously published under Q40887

SUMMARY

Below is a Macintosh QuickBASIC Version 1.00 program that makes a file invisible on the Macintosh desktop. Even though it is invisible, the file can still be accessed by an application and can be read and written to, e.g. QuickBASIC can still open the file.

The program example uses the GetFileInfo and SetFileInfo routines (i.e., MBLC routines in QuickBASIC), which are not provided in earlier releases of BASIC interpreter or compiler for Macintosh.

MORE INFORMATION

The following is a program example:

' Hides a visible file or unhides an invisible file
DEFINT A-Z
DIM FILEINFO(40)
FILENAME$ = "myfile"
GetFileInfo FILENAME$,FILEINFO(0)
FILEINFO(20) = FILEINFO(20) XOR 16384
SetFileInfo FILENAME$,FILEINFO(0)
END
                

The contents of the FILEINFO array can be found in "Inside Macintosh" Volume II on Page 116 (by Apple Inc., published by Addison-Wesley). In this array, the Finder information is stored in parameter block 32 (i.e., element 16 in the array). The Finder information block is 16 bytes long. These 16 bytes are described on Page 130. They are as follows:

   fdType      OStype {file type}
   fdCreator   OStype {file's creator}
   fdFlags     INTEGER {flags}
   fdLocation  Point {file's location}
   fdFldr      INTEGER {file's window}
                

The fdFlags are used to determine if the file is visible to the Finder. The constant 16384 is XORed to the flag's value to determine if the file should be visible or not.


Additional query words: MQuickB

Keywords: KB40887