Macintosh QuickBASIC Program to Hide/Unhide File in Finder

This article was previously published under Q40887
This article has been archived. It is offered "as is" and will no longer be updated.
Below is a Macintosh QuickBASIC Version 1.00 program that makes a fileinvisible on the Macintosh desktop. Even though it is invisible, thefile can still be accessed by an application and can be read andwritten 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 earlierreleases of BASIC interpreter or compiler for Macintosh.
The following is a program example:
' Hides a visible file or unhides an invisible fileDEFINT A-ZDIM FILEINFO(40)FILENAME$ = "myfile"GetFileInfo FILENAME$,FILEINFO(0)FILEINFO(20) = FILEINFO(20) XOR 16384SetFileInfo 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). Inthis array, the Finder information is stored in parameter block 32(i.e., element 16 in the array). The Finder information block is 16bytes long. These 16 bytes are described on Page 130. They are asfollows:
   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 theFinder. The constant 16384 is XORed to the flag's value to determineif the file should be visible or not.

Article ID: 40887 - Last Review: 02/27/2014 20:59:27 - Revision: 1.2

  • kbnosurvey kbarchive KB40887