Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Programatically set Today background Image

23 views
Skip to first unread message

- robins @ntlworlddotcom Martin Robins

unread,
Sep 9, 2003, 4:34:32 PM9/9/03
to
I wish to set the "Today" background image programatically but do not seem
to be able to.

I have tried setting the registry value HKCU\Software\Microsoft\Today\Skin =
\My Documents\MyFile.tsk but this does not seem to be enough on its own.

Is there an API I can call?

I am using .NET CF on PPC2002.

Thanks.


Amit

unread,
Sep 10, 2003, 1:16:26 PM9/10/03
to
Check it out...
http://www.pocketpcdn.com/articles/changetodaytheme.html
Though ex is in eVC....but it will give you the idea...
Regards
Amit
"Martin Robins" <martin - robins @ ntlworld dot com> wrote in message
news:O23cIHxd...@TK2MSFTNGP12.phx.gbl...

- robins @ntlworlddotcom Martin Robins

unread,
Sep 11, 2003, 4:18:44 PM9/11/03
to
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.
 
 
 
 
0 new messages