Technical Q&As


TB 19 - How PBDTGetAPPL() Chooses Which Copy of an App to Launch (14-May-96)


Q How does PBDTGetAPPL() choose the "best" copy of an application to launch? Sometimes the choice PBDTGetAPPL() returns information about a copy of the application that happens to be in the Trash. How can I guarantee that the copy of an application I attempt to launch is not in the Trash?

A PBDTGetAPPL is documented in Inside Macintosh: More Macintosh Toolbox. On page 9-5, it states, "In each call to PBDTGetAPPL, you specify a creator (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."

This Inside Macintosh explanation is not really correct. When you specify and creator and pass an index value of 0, PBDTGetAPPL() actually returns information about the LAST copy of the application the Desktop Manager used to update the Desktop database, NOT the copy with the most recent creation date. In other words, PBDTGetAPPL() returns Last-In-First-Out information from the Desktop database.

To avoid launching a copy of the application that is currently in the Trash folder add a check for the application's parent ID. If the "first choice" is in the Trash, then make indexed calls (beginning with an index of 1) to PBDTGetAPPL to get information about all copies of the application and compare the ioAPPLParID and ioTagInfo (creation date) fields to find the copy of the application with the latest creation date that is not currently in the Trash.

Technical Q&As
Previous Question | Contents | Next Question