Google 網路論壇不再支援新的 Usenet 貼文或訂閱項目,但過往內容仍可供查看。

Programatically set Today background Image

瀏覽次數:23 次
跳到第一則未讀訊息

- robins @ntlworlddotcom Martin Robins

未讀,
2003年9月9日 下午4:34:322003/9/9
收件者:
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

未讀,
2003年9月10日 下午1:16:262003/9/10
收件者:
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

未讀,
2003年9月11日 下午4:18:442003/9/11
收件者:
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 則新訊息