How to Set Today theme to default theme.
2008-12-01 15:10
363 查看
以下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;
//}
修改的键主要分布在以下两个:
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;
//}
相关文章推荐
- How to Change Default Grub Theme or Splash Image in Ubuntu 10.10
- How to Change Default Grub Theme or Splash Image in Ubuntu 10.10
- How To Set Dark Theme in Visual Studio 2010
- How to set the default input focus on a field in an HTML web form
- How to Change the Default Theme Appearance [editing with no theme]
- django: BooleanField, how to set the default value to true? - Stack Overflow
- Cognos How to set the default email sender to a specific value
- How to set the DefaultButton in a Page Based on ASP.NET Master Page
- Android问题集锦之二十八:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- You need to use a Theme.AppCompat theme (or descendant) with this activity.
- [eZ publish] How to set the SSL to a node?
- Project has no default.properties file! Edit the project properties to set one
- You need to use a Theme.AppCompat theme (or descendant) with this activity.
- 【我的Android进阶之旅】解决bug:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- Android问题集锦之二十八:You need to use a Theme.AppCompat theme (or descendant) with this activity.
- How to set the width of columns?about chart control for .net
- 如何设置Java桌面程序界面外观(How to Set the Look and Feel)
- Project has no default.properties file! Edit the project properties to set one.错误解决方案
- You need to use a Theme.AppCompat theme (or descendant) with this activity
- Axure RP Pro - jQuery - How to implement the "set focus" action