以下Sample code只是提供了一个方法,可能没有通用性,每个设备的Default skin的键值设置都会有所不同。代码还存在缺陷,Start Menu颜色变不过来,还有待研究。
修改的键主要分布在以下两个:
HKEY_CURRENT_USER/Software/Microsoft/Today/Skin
HKEY_LOCAL_MACHINE/Software/Microsoft/Color
- HKEY hKeyToday = NULL;
- HKEY hKeyColor = NULL;
- HKEY hKeyGWE = NULL;
- LONG lRet;
- PROCESS_INFORMATION pi;
- DWORD cbSize = 0;
- DWORD dwType = REG_BINARY;
- DWORD dwValue = 11588987;
- DWORD dwDPI = 96;
- BYTE *pbColor = NULL;
- //BYTE *pbSysColor = NULL;
- TCHAR szCmdLine[MAX_PATH+1];
- TCHAR pszFile[] = _T("//Windows//Guava Bubbles.tsk");
- //
- // Set the theme
- //
- lRet = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software//Microsoft//Today"), 0, 0, &hKeyToday);
- if(ERROR_SUCCESS != lRet)
- {
- goto Exit;
- }
- RegDeleteValue(hKeyToday, _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, &pi))
- {
- ::WaitForSingleObject(pi.hProcess, INFINITE);
- RegSetValueEx(hKeyToday, _T("Skin"), 0, REG_SZ, (BYTE*)_T(""), 1);
- RegSetValueEx(hKeyToday, _T("DPI"), 0, REG_DWORD, (BYTE*)&dwDPI, sizeof(DWORD));
- lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software//Microsoft//Color"), 0, 0, &hKeyColor);
- if (ERROR_SUCCESS != lRet)
- {
- goto Exit;
- }
- RegQueryValueEx(hKeyColor, _T("DefSHColor"), 0, &dwType, NULL, &cbSize);
- pbColor = new BYTE[cbSize];
- if (!pbColor)
- {
- goto Exit;
- }
- ZeroMemory(pbColor, cbSize);
- RegQueryValueEx(hKeyColor, _T("DefSHColor"), 0, &dwType, pbColor, &cbSize);
- RegSetValueEx(hKeyColor, _T("SHColor"), 0, REG_BINARY, pbColor, cbSize);
- RegSetValueEx(hKeyColor, _T("BaseHue"), 0, REG_DWORD, (BYTE *)&dwValue, sizeof(DWORD));
- //lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("System//GWE"), 0, 0, &hKeyGWE);
- //if (ERROR_SUCCESS != lRet)
- //{
- // goto Exit;
- //}
- //RegQueryValueEx(hKeyGWE, _T("DefSysColor"), 0, &dwType, NULL, &cbSize);
- //pbSysColor = new BYTE[cbSize];
- //if (!pbSysColor)
- //{
- // goto Exit;
- //}
- //ZeroMemory(pbSysColor, cbSize);
- //RegQueryValueEx(hKeyGWE, _T("DefSysColor"), 0, &dwType, pbSysColor, &cbSize);
- //RegSetValueEx(hKeyGWE, _T("SysColor"), 0, REG_BINARY, pbSysColor, cbSize);
- CloseHandle(pi.hThread);
- CloseHandle(pi.hProcess);
- }
- //
- // Broadcast the update today message
- //
- ::PostMessage(HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
- Exit:
if (hKeyToday)
{
RegCloseKey(hKeyToday);
}
if (hKeyColor)
{
RegCloseKey(hKeyColor);
}
if (hKeyGWE)
{
RegCloseKey(hKeyGWE);
}
if (pbColor)
{
delete []pbColor;
}
//if (pbSysColor)
//{
// delete []pbSysColor;
//}