QA: How to install a Today theme file?

Joao Paulo Figueira (joao.fig@mail.telepac.pt), June 02, 2003.

Question

How do I programmatically install a Today theme?

Answer

To change the appearance of your Pocket PC 2002 Today screen, you have to options: select a theme file, or a wallpaper. Themes are more complex than wallpapers. Besides having a background image, themes also implement system-wide colour schemes. Wallpapers are mere replacements of the current skin background image. Installing a Today screen theme is a bit more complex than installing a wallpaper.

To install a Today screen theme do the following:

Here is some sample code:

HKEY hKey; LONG lRet; TCHAR szCmdLine[MAX_PATH+1]; TCHAR* pszFile = _T("\\Windows\\Fire.tsk"); // The theme file // // Set the theme // lRet = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Today"), 0, 0, &hKey); if(ERROR_SUCCESS == lRet) { RegDeleteValue(hKey, _T("UseStartImage")); wcscpy(szCmdLine, _T("/safe /noui /nouninstall /delete 0 ")); wcscat(szCmdLine, pszFile); if(::CreateProcess(_T("\\Windows\\wceload.exe"), szCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, NULL, &amppi)) { ::WaitForSingleObject(pi.hProcess, INFINITE); RegSetValueEx(hKey, _T("Skin"), 0, REG_SZ, (BYTE*)pszFile, sizeof(TCHAR) * (wcslen(pszFile) + 1)); RegCloseKey(hKey); } // // Broadcast the update today message // ::SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0); }

Installing a wallpaper is much simpler, but you have to perform a previous step. Your wallpaper file must be copied into the windows directory with the name of 'tdycust'. Assuming you have a wallpaper file named 'wallpaper.gif' in the \My Documents folder, here is the code you would use to set it:

// // Set the wallpaper // lRet = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Today"), 0, 0, &hKey); if(ERROR_SUCCESS == lRet) { SetKeyValue(hKey, _T("WallFile"), _T("\\windows\\tdycust.gif")); SetKeyValue(hKey, _T("Wall"), _T("Wallpaper")); SetKeyValue(hKey, _T("Watermark"), _T("tdycust.gif")); RegCloseKey(hKey); // // Broadcast the update today message // ::SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0); }

To remove the wallpaper: delete the 'Watermark' value, set 'WallFile' to an empty string, and broadcast the WM_WININICHANGE message, just like in the above example.

Related resources: