pete moss wrote:
> the docs say nothing about [PrefGetAppPreferences] returning the
> version number. they say it returns a constant if no prefs
> available, and some other number otherwise.
[ Attention David Fedor! Doc feedback below... ]
You're right, the *.pdf documentation is inadequate, though the docs in
*.c format are very accurate about this behavior. :-)
> it doesnt say what this number is, just suggests that you compare it
> to the size of your struct.
Actually it's not the function return value but the prefsSize in/out
parameter that returns the size of the preference structure. (That's
why it's passed by reference instead of by value.)
> does the prefs database ever get deleted?
No, the "Saved Preferences" and "Unsaved Preferences" databases exist
permanently for the whole system. Each app preference is a single
resource in one of those two db's.
> is that one thing that gets removed when an app is deleted?
Yes. (As long as you use Applications Launcher interface and not a
hacker utility or the DmDeleteDatabase API, of course.)
> if so, what if you dont delete the app but just overwrite it with a
> new copy that may create a new 'version' of the prefs. does the old
> version ever get deleted?
The PrefSetAppPreferences API overwrites any previous pref that has the
same creatorID, prefID, and saved flag. It's a simple design -- your
pref is just a resource in a system prefs database. The saved flag
determines which one ("Unsaved Preferences" or "Saved Preferences") and
the creatorID and prefID become the resType and resID of the resource.
The version you give PrefSetAppPreferences is just stashed in the first
2 bytes of the stored resource, and then PrefGetAppPreferences strips it
and returns it.
-slj-