Accessing Stored Font and Color Settings
The Visual Studio integrated development environment (IDE) stores modified settings for fonts and colors in the registry. You can use the IVsFontAndColorStorage interface to access these settings.
Font and color information is stored by category in the following registry location: [HKCU\SOFTWARE\Microsoft \Visual Studio\<Visual Studio version>\FontAndColors\<CategoryGUID>], where <CategoryGUID> is the category GUID.
Therefore, to initiate persistence, a VSPackage must:
Obtain an IVsFontAndColorStorage interface by calling QueryService against the global service provider.
QueryService must be called by using a service ID argument of SID_SVsFontAndColorStorage and an interface ID argument of IID_IVsFontAndColorStorage.
Use the OpenCategory method to open a category to be persisted by using the category's GUID and a mode flag as arguments.
The mode, specified by the fFlags argument, is constructed from values in the __FCSTORAGEFLAGS enumeration. This mode controls:
Persisting fonts and colors involves:
Synchronizing the IDE settings with settings stored in the registry.
Propagating registry modification information.
Setting and retrieving settings stored in the registry.
Synchronizing the storage setting with the IDE settings is largely transparent. The underlying IDE automatically writes updated settings for Display Items to the registry entries of categories.
If multiple VSPackages share a particular category, a VSPackage should require that events are generated when methods of the IVsFontAndColorStorage interface are used to modify stored registry settings.
By default, event generation is not enabled. To enable event generation, a category must be opened by using FCSF_PROPAGATECHANGES. This causes the IDE to call the appropriate IVsFontAndColorEvents method that a VSPackage implements.
Modifications through the Font and Color property page generate events independent of IVsFontAndColorStorage. You can use the IVsFontAndColorCacheManager interface to determine whether an update of cached font and color settings is needed before calling the methods of the IVsFontAndColorStorage class.
The fFlags argument that is passed to the OpenCategory method when that category was opened defines the behavior of the GetItem and the GetFont methods. By default, these methods only return information about display items that have changed. However, if a category is opened by using the FCSF_LOADDEFAULTS flag, both updated and unchanged display items can be accessed by GetItem and GetFont.
By default, only changed Display Items information is kept in the registry. The IVsFontAndColorStorage interface cannot be used to retrieve all settings for fonts and colors.
The settings of all Display Items in a particular Category can be obtained by using the methods of the T:Microsoft.VisualStudio.Shell.Interop.IVsFontAndColorDefaults interface.