Set theme / wallpaper
-
Does anybody know how to programatically set the desktop wallpaper in PocketPC 2002? Besides using the registry and soft-resetting the device, I don't know of a cleaner way...
-
Does anybody know how to programatically set the desktop wallpaper in PocketPC 2002? Besides using the registry and soft-resetting the device, I don't know of a cleaner way...
Sorry for replying to my own post, but I found an answer for this. Here is the code:
PROCESS\_INFORMATION pi; CString strCmdLine(\_T("/safe /noui /nouninstall /delete 0 ")), strFile; HKEY hKey; LONG lRet; m\_edtFile.GetWindowText(strFile); strCmdLine += strFile; if(::CreateProcess(\_T("\\\\Windows\\\\wceload.exe"), strCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi)) { ::WaitForSingleObject(pi.hProcess, INFINITE); lRet = RegOpenKeyEx(HKEY\_CURRENT\_USER, \_T("\\\\Software\\\\Microsoft\\\\Today"), 0, 0, &hKey); if(ERROR\_SUCCESS == lRet) { RegSetValueEx(hKey, \_T("Skin"), 0, REG\_SZ, (BYTE\*)(LPCTSTR)strFile, sizeof(TCHAR) \* (strFile.GetLength() + 1)); RegCloseKey(hKey); ::SendMessage(HWND\_BROADCAST, WM\_WININICHANGE, 0xF2, 0); } }
Note:
strFile
contains the full path name of the .tsk file. No reset is needed. -
Sorry for replying to my own post, but I found an answer for this. Here is the code:
PROCESS\_INFORMATION pi; CString strCmdLine(\_T("/safe /noui /nouninstall /delete 0 ")), strFile; HKEY hKey; LONG lRet; m\_edtFile.GetWindowText(strFile); strCmdLine += strFile; if(::CreateProcess(\_T("\\\\Windows\\\\wceload.exe"), strCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi)) { ::WaitForSingleObject(pi.hProcess, INFINITE); lRet = RegOpenKeyEx(HKEY\_CURRENT\_USER, \_T("\\\\Software\\\\Microsoft\\\\Today"), 0, 0, &hKey); if(ERROR\_SUCCESS == lRet) { RegSetValueEx(hKey, \_T("Skin"), 0, REG\_SZ, (BYTE\*)(LPCTSTR)strFile, sizeof(TCHAR) \* (strFile.GetLength() + 1)); RegCloseKey(hKey); ::SendMessage(HWND\_BROADCAST, WM\_WININICHANGE, 0xF2, 0); } }
Note:
strFile
contains the full path name of the .tsk file. No reset is needed.Oh, I always reply to my own posts. 7/8 of the time, I find out my own answer. But I know that others want to know the answer too, and replying to myself is a good way to let them in on the solution, too. ;):)
"Do unto others as you would have them do unto you." - Jesus
"An eye for an eye only makes the whole world blind." - Mahatma Gandhi -
Sorry for replying to my own post, but I found an answer for this. Here is the code:
PROCESS\_INFORMATION pi; CString strCmdLine(\_T("/safe /noui /nouninstall /delete 0 ")), strFile; HKEY hKey; LONG lRet; m\_edtFile.GetWindowText(strFile); strCmdLine += strFile; if(::CreateProcess(\_T("\\\\Windows\\\\wceload.exe"), strCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi)) { ::WaitForSingleObject(pi.hProcess, INFINITE); lRet = RegOpenKeyEx(HKEY\_CURRENT\_USER, \_T("\\\\Software\\\\Microsoft\\\\Today"), 0, 0, &hKey); if(ERROR\_SUCCESS == lRet) { RegSetValueEx(hKey, \_T("Skin"), 0, REG\_SZ, (BYTE\*)(LPCTSTR)strFile, sizeof(TCHAR) \* (strFile.GetLength() + 1)); RegCloseKey(hKey); ::SendMessage(HWND\_BROADCAST, WM\_WININICHANGE, 0xF2, 0); } }
Note:
strFile
contains the full path name of the .tsk file. No reset is needed.How did you find this way :wtf: ? Did you show how values / keys are changed in the registry during changing the wallpaper / today screen? Daniel ;) --------------------------- Never change a running system!
-
How did you find this way :wtf: ? Did you show how values / keys are changed in the registry during changing the wallpaper / today screen? Daniel ;) --------------------------- Never change a running system!
It was a long process of looking into partial clues. I found one clue in the registry key
HKEY_CLASSES_ROOT\tdyskin\Shell\Open\Command
. Then I found an answer to a similar question in a newsgroup saying that you need to broadcast a message after setting the skin (by Vassili Phillipov). Suddenly, something flashed in my mind and voilá! This approach has a problem, though. If you have an installed CF card with an actionable Autorun.exe, your wallpaper will not be correctly set. I'm looking into this issue. -
It was a long process of looking into partial clues. I found one clue in the registry key
HKEY_CLASSES_ROOT\tdyskin\Shell\Open\Command
. Then I found an answer to a similar question in a newsgroup saying that you need to broadcast a message after setting the skin (by Vassili Phillipov). Suddenly, something flashed in my mind and voilá! This approach has a problem, though. If you have an installed CF card with an actionable Autorun.exe, your wallpaper will not be correctly set. I'm looking into this issue.Wow :omg: ... Another great detective work ... YOu should work for the police ;). Daniel ;) --------------------------- Never change a running system!
-
Wow :omg: ... Another great detective work ... YOu should work for the police ;). Daniel ;) --------------------------- Never change a running system!
Daniel S. wrote: YOu should work for the police Nah... They have to work with all sorts of nasty issues and terrible people. I'd rather investigate these harmless issues and share them with all of you bright CPians. Thanks for your compliment! ;) João Paulo
-
Does anybody know how to programatically set the desktop wallpaper in PocketPC 2002? Besides using the registry and soft-resetting the device, I don't know of a cleaner way...
I found a bug in the code I posted before. When you change from the Bliss theme to any other one, you will get a painting error on the Today screen. This is because the code I posted did not delete the
UseStartImage
value. You have to delete it before sending the broadcast message to the desktop. Here is the revised code:PROCESS_INFORMATION pi;
CString strCmdLine(_T("/safe /noui /nouninstall /delete 0 ")),
strFile;
HKEY hKey;
LONG lRet;m_edtFile.GetWindowText(strFile);
strCmdLine += strFile;lRet = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Today"), 0, 0,
&hKey);
if(ERROR_SUCCESS == lRet)
{
RegDeleteValue(hKey, _T("UseStartImage"));if(::CreateProcess(\_T("\\\\Windows\\\\wceload.exe"), strCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi)) { ::WaitForSingleObject(pi.hProcess, INFINITE); RegSetValueEx(hKey, \_T("Skin"), 0, REG\_SZ, (BYTE\*)(LPCTSTR)strFile, sizeof(TCHAR) \* (strFile.GetLength() + 1)); RegCloseKey(hKey); ::SendMessage(HWND\_BROADCAST, WM\_WININICHANGE, 0xF2, 0); }
}
As before,
strFile
contains the full path skin file name. -
Wow :omg: ... Another great detective work ... YOu should work for the police ;). Daniel ;) --------------------------- Never change a running system!
New post. Check it out! The bug is corrected.
-
I found a bug in the code I posted before. When you change from the Bliss theme to any other one, you will get a painting error on the Today screen. This is because the code I posted did not delete the
UseStartImage
value. You have to delete it before sending the broadcast message to the desktop. Here is the revised code:PROCESS_INFORMATION pi;
CString strCmdLine(_T("/safe /noui /nouninstall /delete 0 ")),
strFile;
HKEY hKey;
LONG lRet;m_edtFile.GetWindowText(strFile);
strCmdLine += strFile;lRet = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Today"), 0, 0,
&hKey);
if(ERROR_SUCCESS == lRet)
{
RegDeleteValue(hKey, _T("UseStartImage"));if(::CreateProcess(\_T("\\\\Windows\\\\wceload.exe"), strCmdLine, NULL, NULL, FALSE, 0, NULL, NULL, NULL, &pi)) { ::WaitForSingleObject(pi.hProcess, INFINITE); RegSetValueEx(hKey, \_T("Skin"), 0, REG\_SZ, (BYTE\*)(LPCTSTR)strFile, sizeof(TCHAR) \* (strFile.GetLength() + 1)); RegCloseKey(hKey); ::SendMessage(HWND\_BROADCAST, WM\_WININICHANGE, 0xF2, 0); }
}
As before,
strFile
contains the full path skin file name.Thanks! Daniel ;) --------------------------- Never change a running system!