Geoff Chappell - Software Analyst
VOID SHInitializeControlPanelRegkeys (VOID);
The function reliably returns 0 or 1 (from the CPVIEW enumeration) depending on whether the Control Panel is set for the classic or category view. However, this seems likely to be an implementation detail, not the functional design.
As presently implemented, the function gets the current Control Panel view. Indeed, except for not having to create an OpenControlPanel object, it is essentially equivalent to calling the GetCurrentView method of that object’s IOpenControlPanel interface. The attitude of these notes is that the point to exporting this function is not to get the current view but to ensure that it is well-defined.
In any sort of Safe Mode, the Control Panel is necessarily in Classic View and there is nothing to check or initialise. The function simply returns CPVIEW_CLASSIC.
Ordinarily, the record of the chosen Control Panel view is supported from a registry value
|Data:||1 to use Category View, else 0|
|Default:||0 if running on a server, else 1|
and the function makes sure that this value is correctly set. This value is meant to be a boolean indicator of whether the Control Panel is in Category View. Unlike many registry values, this one actually is checked for strict conformance to expectations. It must have the REG_DWORD type and its dword of data must be 0 or 1. Otherwise, it is treated as undefined and will have to be set anew. The function chooses Classic View if running on a server edition of Windows, else Category View.
Whether the RecentView value is well-defined or not, it may be overridden by an administrative policy to force either view:
|Data:||0 to force Category View;
1 to force Classic View;
else do not force a view
If the data for this setting is 0 or 1, then the RecentView value will have to be set to 1 or 0, respectively.
Incidentally, the ForceClassicControlPanel setting has user-interface support through the Group Policy Object Editor, as “Force classic Control Panel view” in the Control Panel administrative template (in the User Configuration branch only).
If the RecentView setting is well-defined and there is no (valid) ForceClassicControlPanel policy, then the function returns CPVIEW_CLASSIC (0) or CPVIEW_CATEGORY (1) according to whether RecentView is already 0 or 1, respectively. If the RecentView setting is not well-defined or a view is forced by policy and disagrees with what’s presently in RecentView, then the function rewrites the RecentView value. If this succeeds, then the function has two other values to update and a notification to send.
The two other values are the attributes for the two Control Panel views as shell folders. The SFGAO_NONENUMERATED attribute must be set for whichever is not the current view and be clear for whichever is. Keeping this right is particularly important for the desktop, since both Control Panel views are required items in the ShellDesktop class. Indeed, if the Control Panel is configured to show as an icon on the desktop, then to set this attribute is effectively to delete the icon. (This is why the Control Panel icon may move when you change the Control Panel view. The icon for the old view is deleted and the icon for the new view is added, and is given a default position.) The attributes are set in the per-user CLSID key (in the sense of the SHRegGetCLSIDKey function):
in which clsid stands for
The SFGAO_NONENUMERATED attribute is just one bit (0x01000000) in the dword of data. Other bits are preserved either from this same value, if it can be read, else from the machine value:
Provided that attibutes are set for both the Control Panel classes, the function then sends an SHCNE_UPDATEDIR notification, to tell anyone who cares that the desktop folder has changed.
The SHInitializeControlPanelRegkeys function is exported from SHELL32.DLL as ordinal 852 in the version 6.00 from Windows Vista, and higher.
This function was not documented by Microsoft for the January 2007 edition of the Windows Vista Software Development Kit (SDK).