In the last Microsoft Windows CE chat, someone asked about setting the Explorer Task Bar to auto hide by default. The problem is that the value that controls auto hide is the default value for the key. Default key values are defined in reg files using @=dword:1, which is not supported by Platform Builder’s fmerge.
One solution would be to clone the Explorer shell and modify it so that the default value is set to TRUE. But that is a big hammer for a very small nail, isn’t it?
Another solution would be to modify the registry after the system boots, but before Explorer starts. Hopefully you already have an application that you run when the system boots. Having an application like that can be quite valuable for doing things like calling TouchCalibrate() to calibrate a touch panel and modifying the registry. The following function can then be called from this startup application to set the Task Bar to auto hide:
#define AUTOHIDE_SUBKEY TEXT("Software\\Microsoft\\Shell\\AutoHide")
void SetAutoHide()
{
    DWORD Status;
    DWORD dwDisp;
    HKEY hKey;
                DWORD Value = 1;
 
    Status = RegOpenKeyEx(
                                HKEY_LOCAL_MACHINE,
                                AUTOHIDE_SUBKEY,
                                0,
                                KEY_ALL_ACCESS,
                                &hKey);
    if (Status != ERROR_SUCCESS)
    {
                Status = RegCreateKeyEx(
                                                HKEY_LOCAL_MACHINE,
                                                AUTOHIDE_SUBKEY,
                                                0,
                                                NULL,
                                                0,
                                                KEY_ALL_ACCESS,
                                                NULL,
                                                &hKey,
                                                &dwDisp);
    }
 
    if (Status == ERROR_SUCCESS)
                {
                                RETAILMSG( 1, (TEXT("Key Opened\n")));
                                if( ERROR_SUCCESS != RegSetValueEx( hKey,TEXT(""), 0, REG_DWORD, (BYTE *)&Value, sizeof(DWORD) ) )
                                                RETAILMSG( 1, (TEXT("Failed to set value%d\n"), GetLastError()));
                                RegCloseKey( hKey );
                }
}
It is a simple function, it tries to open the key, if that fails it creates the key, then it writes a one to the key’s default value.
This function could easily be expanded to read a value from the registry that you can actually set in a Platform Builder reg file, then write that value to the key’s default value.
There are certainly other ways to do this, like calling the function from a driver or implementing the OEMIoControl IOCTL IOCTL_HAL_INITREGISTRY.
Copyright © 2009 – Bruce Eitman
All Rights Reserved