Sometimes we'd like to read the system preferences, so we can use the information to have our application respond to it.
A great resource, which appears to hard to find at times, is Lazarus Wiki - Mac Preferences Read and Write page which shows you how to use this to store your own preferences and my purpose was reading system settings/preferences. At least this got me started with a simple solution to read system settings, even the not so standard ones.
In my situation I wanted to read the "reduceTransparency" setting, which is found in "com.apple.universalaccess" (file: ~/Library/Preferences/com.apple.universalaccess).
First fo all, your application needs to use the units MacOSAll and CFPreferences;
uses MacOSAll, CFPreferences;
Note: CFPreferences is not needed if your project already uses CocoaAll.
Next we need two variables, one as a status value (key exists) and one depending on the returning datatype:
var
IsValid: Boolean; // On return indicates if key exists and has valid data
Pref: Integer;
Reading the value then becomes relatively easy:
Pref := CFPreferencesGetAppIntegerValue(CFStr('reduceTransparency'),CFSTR('com.apple.universalaccess'),IsValid);
Note: if the key value does not exist, expect IsValid to be FALSE.
Note: for different datatypes you'll also find:
CFPreferencesGetAppIntegerValue
CFPreferencesGetAppBooleanValue
Using strings and arrays will be a little more challenging.