Amit,
Thanks very much. I have been able to convert this
code into C# and can now sucessfully change the theme of the Today screen as
desired.
For those who wish to do the same, here is the code
I used...
static void
SetTodayScreenBackground(string fileName) {
// Gain access to the Today
registry key ...
RegistryKey todayKey =
Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Today");
// UseStartImage is specific
to the "Bliss" scheme ...
todayKey.DeleteValue(@"UseStartImage",
false);
// Install the required theme
...
ProcessInfo pi =
new ProcessInfo();
if
(CreateProcess(@"\Windows\wceload.exe", @"/safe /noui /nouninstall /delete 0 " +
"\"" + fileName + "\"", IntPtr.Zero, IntPtr.Zero, 0, 0,
IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, pi)
!= 0) {
WaitForSingleObject(pi.hProcess,
0xFFFFFFFF);
CloseHandle(pi.hProcess);
todayKey.SetValue(@"Skin",
fileName);
todayKey.Flush();
}
SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0xf2,
0);
}
[DllImport(@"coredll.dll", SetLastError=
true)]
private extern static int CloseHandle(
IntPtr hObject);
[DllImport(@"coredll.dll", SetLastError=
true)]
private extern static int CreateProcess(
string imageName,
string cmdLine,
IntPtr lpProcessAttributes,
IntPtr lpThreadAttributes,
int boolInheritHandles,
int dwCreationFlags,
IntPtr lpEnvironment,
IntPtr lpszCurrentDir,
IntPtr si,
ProcessInfo pi);
[DllImport("coredll.dll")]
private static extern int SendMessage(
int hWnd,
int iMsg,
int wParam,
int lParam);
[DllImport(@"coredll.dll", SetLastError=
true)]
private extern static int WaitForSingleObject(
IntPtr hProcess,
uint dwFlag);
I am using the OpenNETCF.Win32 Registry class to
access the registry and this will obviously have to be included or referenced in
your project.
Simply pass the full path and name of the ".tsk"
file that you wish to use as the parameter to the function and the theme will be
installed.
Cheers.