From: Lisa Pearlson on
Hi,

In my CESetup.dll I wish to install a theme.

I created this function:

BOOL LoadTheme(LPCTSTR pszThemeFile)
{
HKEY hKey;
LONG lRet;
TCHAR szCmdLine[MAX_PATH];
PROCESS_INFORMATION pi;

lRet = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Today"), 0,
0, &hKey);
if(ERROR_SUCCESS == lRet) {
RegDeleteValue(hKey, _T("UseStartImage"));
_stprintf(szCmdLine,_T("/safe /noui /nouninstall /delete 0 \"%s\""),
pszThemeFile);
if(CreateProcess(_T("\\Windows\\wceload.exe"), szCmdLine, NULL, NULL,
FALSE, 0, NULL, NULL, NULL, &pi)) {
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
RegSetValueEx(hKey, _T("Skin"), 0, REG_SZ, (BYTE*)pszThemeFile,
sizeof(TCHAR) * (_tcsclen(pszThemeFile) + 1));
RegFlushKey(hKey);
}
RegCloseKey(hKey);
::SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
::SendMessage(HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0);
}

return (ERROR_SUCCESS == lRet);
}


When I call this function from an EXE, it works.. theme loads and screen is
refreshed and theme is displayed properly:

int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
VERIFY(LoadTheme(_T('\\Windows\\MyTheme.tsk"));
}

But when I do the same from within CESetup.dll to be used with CAB install
(where MyTheme.tsk file is copied to \\Windows first), it fails:

codeINSTALL_EXIT
Install_Exit(HWND hwndParent,
LPCTSTR pszInstallDir,
WORD cFailedDirs,
WORD cFailedFiles,
WORD cFailedRegKeys,
WORD cFailedRegVals,
WORD cFailedShortcuts
)
{
VERIFY(LoadTheme(_T('\\Windows\\MyTheme.tsk"));
}


The functions do not fail, I check that theme file exists.. all seems to
succeed, the screen even flickers briefly, most likely in response to
WM_WININICHANGE and WM_SYSCOLORCHANGE, but theme does not show.

Does anyone know why?

I'm using eVC++ 4.0 and its CabWiz.exe tool.
Application runs on WM5 device.

Lisa


From: Mike Harris [MSFT] on
I'm guessing it fails because, when you run it from your cesetup.dll,
wceload.exe is already loaded and running your cab that contains the
cesetup.dll. When wceload.exe is started, it will check if it is already
running in another process and exit without doing anything if it is.
-mike

--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Lisa Pearlson" <no(a)spam.plz> wrote in message
news:udDQQQSNHHA.2232(a)TK2MSFTNGP02.phx.gbl...
> Hi,
>
> In my CESetup.dll I wish to install a theme.
>
> I created this function:
>
> BOOL LoadTheme(LPCTSTR pszThemeFile)
> {
> HKEY hKey;
> LONG lRet;
> TCHAR szCmdLine[MAX_PATH];
> PROCESS_INFORMATION pi;
>
> lRet = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Today"),
> 0, 0, &hKey);
> if(ERROR_SUCCESS == lRet) {
> RegDeleteValue(hKey, _T("UseStartImage"));
> _stprintf(szCmdLine,_T("/safe /noui /nouninstall /delete 0 \"%s\""),
> pszThemeFile);
> if(CreateProcess(_T("\\Windows\\wceload.exe"), szCmdLine, NULL, NULL,
> FALSE, 0, NULL, NULL, NULL, &pi)) {
> WaitForSingleObject(pi.hProcess, INFINITE);
> CloseHandle( pi.hProcess );
> CloseHandle( pi.hThread );
> RegSetValueEx(hKey, _T("Skin"), 0, REG_SZ, (BYTE*)pszThemeFile,
> sizeof(TCHAR) * (_tcsclen(pszThemeFile) + 1));
> RegFlushKey(hKey);
> }
> RegCloseKey(hKey);
> ::SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
> ::SendMessage(HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0);
> }
>
> return (ERROR_SUCCESS == lRet);
> }
>
>
> When I call this function from an EXE, it works.. theme loads and screen
> is refreshed and theme is displayed properly:
>
> int WINAPI WinMain( HINSTANCE hInstance,
> HINSTANCE hPrevInstance,
> LPTSTR lpCmdLine,
> int nCmdShow)
> {
> VERIFY(LoadTheme(_T('\\Windows\\MyTheme.tsk"));
> }
>
> But when I do the same from within CESetup.dll to be used with CAB install
> (where MyTheme.tsk file is copied to \\Windows first), it fails:
>
> codeINSTALL_EXIT
> Install_Exit(HWND hwndParent,
> LPCTSTR pszInstallDir,
> WORD cFailedDirs,
> WORD cFailedFiles,
> WORD cFailedRegKeys,
> WORD cFailedRegVals,
> WORD cFailedShortcuts
> )
> {
> VERIFY(LoadTheme(_T('\\Windows\\MyTheme.tsk"));
> }
>
>
> The functions do not fail, I check that theme file exists.. all seems to
> succeed, the screen even flickers briefly, most likely in response to
> WM_WININICHANGE and WM_SYSCOLORCHANGE, but theme does not show.
>
> Does anyone know why?
>
> I'm using eVC++ 4.0 and its CabWiz.exe tool.
> Application runs on WM5 device.
>
> Lisa
>


From: Lisa Pearlson on
This is my guess too.. however, I have seen it work!
Someone else created a cesetup.dll that did load the theme properly.

Anyway, let's assume it can't work this way (and I certainly tried just
about everything), how can I make it work?
A workaround might be for me to make a copy of wceload.exe under a different
name, and use that one instead?
Not sure I can make a copy of it, protected in rom.
But that should work, right? Inless wceload checks for it's instance by
means of a named mutex or something.

I am more interested in understanding how the theme loader loads a theme..
does it use wceload too or does it use dll or something that wceload uses
too?

Lisa

"Mike Harris [MSFT]" <mike.harris(a)online.microsoft.com> wrote in message
news:%238qsVuNOHHA.4992(a)TK2MSFTNGP04.phx.gbl...
> I'm guessing it fails because, when you run it from your cesetup.dll,
> wceload.exe is already loaded and running your cab that contains the
> cesetup.dll. When wceload.exe is started, it will check if it is already
> running in another process and exit without doing anything if it is.
> -mike
>
> --
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> "Lisa Pearlson" <no(a)spam.plz> wrote in message
> news:udDQQQSNHHA.2232(a)TK2MSFTNGP02.phx.gbl...
>> Hi,
>>
>> In my CESetup.dll I wish to install a theme.
>>
>> I created this function:
>>
>> BOOL LoadTheme(LPCTSTR pszThemeFile)
>> {
>> HKEY hKey;
>> LONG lRet;
>> TCHAR szCmdLine[MAX_PATH];
>> PROCESS_INFORMATION pi;
>>
>> lRet = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Today"),
>> 0, 0, &hKey);
>> if(ERROR_SUCCESS == lRet) {
>> RegDeleteValue(hKey, _T("UseStartImage"));
>> _stprintf(szCmdLine,_T("/safe /noui /nouninstall /delete 0 \"%s\""),
>> pszThemeFile);
>> if(CreateProcess(_T("\\Windows\\wceload.exe"), szCmdLine, NULL, NULL,
>> FALSE, 0, NULL, NULL, NULL, &pi)) {
>> WaitForSingleObject(pi.hProcess, INFINITE);
>> CloseHandle( pi.hProcess );
>> CloseHandle( pi.hThread );
>> RegSetValueEx(hKey, _T("Skin"), 0, REG_SZ, (BYTE*)pszThemeFile,
>> sizeof(TCHAR) * (_tcsclen(pszThemeFile) + 1));
>> RegFlushKey(hKey);
>> }
>> RegCloseKey(hKey);
>> ::SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);
>> ::SendMessage(HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0);
>> }
>>
>> return (ERROR_SUCCESS == lRet);
>> }
>>
>>
>> When I call this function from an EXE, it works.. theme loads and screen
>> is refreshed and theme is displayed properly:
>>
>> int WINAPI WinMain( HINSTANCE hInstance,
>> HINSTANCE hPrevInstance,
>> LPTSTR lpCmdLine,
>> int nCmdShow)
>> {
>> VERIFY(LoadTheme(_T('\\Windows\\MyTheme.tsk"));
>> }
>>
>> But when I do the same from within CESetup.dll to be used with CAB
>> install (where MyTheme.tsk file is copied to \\Windows first), it fails:
>>
>> codeINSTALL_EXIT
>> Install_Exit(HWND hwndParent,
>> LPCTSTR pszInstallDir,
>> WORD cFailedDirs,
>> WORD cFailedFiles,
>> WORD cFailedRegKeys,
>> WORD cFailedRegVals,
>> WORD cFailedShortcuts
>> )
>> {
>> VERIFY(LoadTheme(_T('\\Windows\\MyTheme.tsk"));
>> }
>>
>>
>> The functions do not fail, I check that theme file exists.. all seems to
>> succeed, the screen even flickers briefly, most likely in response to
>> WM_WININICHANGE and WM_SYSCOLORCHANGE, but theme does not show.
>>
>> Does anyone know why?
>>
>> I'm using eVC++ 4.0 and its CabWiz.exe tool.
>> Application runs on WM5 device.
>>
>> Lisa
>>
>
>


 | 
Pages: 1
Prev: scheduler
Next: Did you find the sample code