Using the Desktop Database
You can manipulate the desktop database with a set of low-level routines that
follow the parameter-block conventions used by the File Manager. The desktop database functions use the DTPBRec parameter block. not have a desktop database, call PBHGetVolParms to verify that the target functions.
Because the Finder uses the desktop database, the database is almost always a reference number that represents the access path. Use the PBDTGetPath function to get the reference number, which you must specify when calling
the desktop database is not open, PBDTGetPath opens it. If you are manipulating the database in the absence of the Finder, you can functions as PBDTGetPath and also sets a flag to tell your application whether the desktop database was empty when it was opened. Your application
should never close the database.
different kinds of information in the database. Not all manipulations are
possible with all kinds of data.
You can retrieve five kinds of information from the database:
• icon definitions
• file types and icon types supported by a known creator
• name and location of applications with a known creator
• user comments for a file or a directory
• size and parent directory of the desktop database
To retrieve an icon definition, call PBDTGetIcon. You must specify a file creator, file type, and icon type. The database recognizes both large and small
icons, with 1, 4, or 8 bits of color encoding. (See the description of icons in
To step through a list of all the icon types supported by an application, make
you specify a creator and an index value. Set the index to 1 on the first call, and
result code afpItemNotFound. For each entry in the icon list, PBDTGetIconInfo reports the icon type, the file type it is associated with, and the size of its icon data.
To identify the application that can open a file with a given creator, call
(which is the application's signature) and an index value. An index value of 0 retrieves the “first choice” application-that is, the one with the most recent
creation date. By setting the index to 1 on the first call and incrementing it on
each subsequent call until PBDTGetAPPL returns the result code afpItemNotFound, you can make multiple calls to PBDTGetAPPL to find all copies or versions of the application with this signature on the disk. returns the name, parent directory ID, and creation date of each application
in the desktop database.
To retrieve the user comments for a file or directory, call
the comment box of the information window for any desktop object.
Your application should not ordinarily call the functions for adding and
removing data to and from the database. If your application does need to write to
or delete information from the desktop database, it must call PBDTFlush to
update the copy stored on the volume.
The following list summarizes the data manipulation functions.
Icon definitions
remove: -
Icon types supported‹ by an application
write: -
remove: -
Applications with a given creator
User comments
remove: PBDTRemoveComment
Entire desktop database
read: PBDTGetInfo (size and parent of the database)
write: PBDTFlush (updates the copy stored on the volume)
remove: PBDTDelete and PBDTReset (not called by you)