How to Set Today theme to default theme.

以下Sample code只是提供了一个方法,可能没有通用性,每个设备的Default skin的键值设置都会有所不同。代码还存在缺陷,Start Menu颜色变不过来,还有待研究。

修改的键主要分布在以下两个:

HKEY_CURRENT_USER/Software/Microsoft/Today/Skin

HKEY_LOCAL_MACHINE/Software/Microsoft/Color

 

  1.             HKEY hKeyToday = NULL; 
  2.             HKEY hKeyColor = NULL;
  3.             HKEY hKeyGWE = NULL;
  4.             LONG lRet;  
  5.             PROCESS_INFORMATION pi;
  6.             DWORD cbSize = 0;
  7.             DWORD dwType = REG_BINARY;
  8.             DWORD dwValue = 11588987;
  9.             DWORD dwDPI = 96;
  10.             BYTE *pbColor = NULL;
  11.             //BYTE *pbSysColor = NULL;
  12.             TCHAR szCmdLine[MAX_PATH+1];
  13.             TCHAR pszFile[] = _T("//Windows//Guava Bubbles.tsk");
  14.             //
  15.             // Set the theme
  16.             //
  17.             lRet = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software//Microsoft//Today"), 0, 0, &hKeyToday);
  18.             if(ERROR_SUCCESS != lRet)
  19.             {
  20.                 goto Exit;
  21.             }
  22.             RegDeleteValue(hKeyToday, _T("UseStartImage"));
  23.             wcscpy(szCmdLine, _T("/safe /noui /nouninstall /delete 0 "));
  24.             wcscat(szCmdLine, pszFile);
  25.             if(::CreateProcess(_T("//Windows//wceload.exe"),szCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi))
  26.             {
  27.                 ::WaitForSingleObject(pi.hProcess, INFINITE);
  28.                 RegSetValueEx(hKeyToday, _T("Skin"), 0, REG_SZ, (BYTE*)_T(""), 1);
  29.                 RegSetValueEx(hKeyToday, _T("DPI"), 0, REG_DWORD, (BYTE*)&dwDPI, sizeof(DWORD));
  30.                 lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("Software//Microsoft//Color"), 0, 0, &hKeyColor);
  31.                 if (ERROR_SUCCESS != lRet)
  32.                 {
  33.                     goto Exit;
  34.                 }
  35.                 RegQueryValueEx(hKeyColor, _T("DefSHColor"), 0, &dwType, NULL, &cbSize);
  36.                 pbColor = new BYTE[cbSize];
  37.                 if (!pbColor)
  38.                 {
  39.                     goto Exit;
  40.                 }
  41.                 ZeroMemory(pbColor, cbSize);
  42.                 RegQueryValueEx(hKeyColor, _T("DefSHColor"), 0, &dwType, pbColor, &cbSize);
  43.                 RegSetValueEx(hKeyColor, _T("SHColor"), 0, REG_BINARY, pbColor, cbSize);
  44.                 RegSetValueEx(hKeyColor, _T("BaseHue"), 0, REG_DWORD, (BYTE *)&dwValue, sizeof(DWORD)); 
  45.                 //lRet = RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("System//GWE"), 0, 0, &hKeyGWE);
  46.                 //if (ERROR_SUCCESS != lRet)
  47.                 //{
  48.                 //  goto Exit;
  49.                 //}
  50.                 //RegQueryValueEx(hKeyGWE, _T("DefSysColor"), 0, &dwType, NULL, &cbSize);
  51.                 //pbSysColor = new BYTE[cbSize];
  52.                 //if (!pbSysColor)
  53.                 //{
  54.                 //  goto Exit;
  55.                 //}
  56.                 //ZeroMemory(pbSysColor, cbSize);
  57.                 //RegQueryValueEx(hKeyGWE, _T("DefSysColor"), 0, &dwType, pbSysColor, &cbSize);
  58.                 //RegSetValueEx(hKeyGWE, _T("SysColor"), 0, REG_BINARY, pbSysColor, cbSize);
  59.                 CloseHandle(pi.hThread);
  60.                 CloseHandle(pi.hProcess);
  61.             }
  62.             //
  63.             // Broadcast the update today message
  64.             //
  65.             ::PostMessage(HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
  66. Exit:
       if (hKeyToday)
       {
        RegCloseKey(hKeyToday);
       }
       if (hKeyColor)
       {
        RegCloseKey(hKeyColor);
       }
       if (hKeyGWE)
       {
        RegCloseKey(hKeyGWE);
       }
       if (pbColor)
       {
        delete []pbColor;
       }
       //if (pbSysColor)
       //{
       // delete []pbSysColor;
       //}

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值