Changing the Today screen image?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all,

Does anyone have a example of setting the today screens image to another file?
I am looking to build my first PPC app and decide to do a wallpaper changer.
Wow finding documentation on this is not easy!
I would like to do this in VB.net or C3.net.

Could anyone give me some pointers here?

Thanks
 
Hi,

Try to change this registry key : HKEY_CURRENT_USER\ControlPanel\Home
with your new image path and send a Windows Message to refresh the
today screen.
In C#, you must import the SendMessage function:

SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE,
SPI_SETDESKWALLPAPER, 0)

the import:
[DllImport("coredll.dll")]
private static extern int SendMessage(IntPtr hWnd, uint msg, int
wParam, int lParam);

BR

Fabien Decret (Device Application Development MVP)
Windows Embedded Consultant

ADENEO (ADESET)
http://www.adeneo.adetelgroup.com/ | http://fabdecret.blogspot.com/
 
Thank you for your reply Fabien.
I tried what you said and I keep getting a Unautherizedaccess error!

Code I am currently trying is; [VB.net code.]

Public Shared HWND_BROADCAST As IntPtr = IntPtr.op_Explicit(&HFFFF)
Public Const WM_WININICHANGE = &H1A
Public Shared SPI_SETDESKTOPWALLPAPER As Integer = 20

'<DllImport("coredll.dll")>
Private Declare Function SendMessage Lib "coredll.dll" Alias "SendMessageA"
(ByVal hWnd As IntPtr, ByVal Msg As System.Int32, ByVal wParam As
System.Int32, ByVal lParam As System.Int32)

private sub SetWallpaper()
Dim strWhoAmI As String = ""
Dim registryKey As Microsoft.Win32.RegistryKey
Dim strValues() As String
try
registryKey = Microsoft.Win32.Registry.CurrentUser '.CurrentUser '
..GetValue("HKEY_CURRENT_USER\ControlPanel\Home")
strValues =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValueNames()
strWhoAmI =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValue("Wallpaper").ToString
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").SetValue("Wallpaper", "\Windows\Guava bubbles.tsk")
strWhoAmI =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValue("Wallpaper").ToString
registryKey.Close()
SendMessage(HWND_BROADCAST, WM_WININICHANGE, SPI_SETDESKTOPWALLPAPER, 0)
Catch ex As Exception

End Try
End Sub

--
Deasun
Home Site: www.tirnaog.com
Check out: The Code Vault in my forums section.


Fabien said:
Hi,

Try to change this registry key : HKEY_CURRENT_USER\ControlPanel\Home
with your new image path and send a Windows Message to refresh the
today screen.
In C#, you must import the SendMessage function:

SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE,
SPI_SETDESKWALLPAPER, 0)

the import:
[DllImport("coredll.dll")]
private static extern int SendMessage(IntPtr hWnd, uint msg, int
wParam, int lParam);

BR

Fabien Decret (Device Application Development MVP)
Windows Embedded Consultant

ADENEO (ADESET)
http://www.adeneo.adetelgroup.com/ | http://fabdecret.blogspot.com/
 
You get an error *WHEN*? What line of code is the problem?

Paul T.

Deasun said:
Thank you for your reply Fabien.
I tried what you said and I keep getting a Unautherizedaccess error!

Code I am currently trying is; [VB.net code.]

Public Shared HWND_BROADCAST As IntPtr = IntPtr.op_Explicit(&HFFFF)
Public Const WM_WININICHANGE = &H1A
Public Shared SPI_SETDESKTOPWALLPAPER As Integer = 20

'<DllImport("coredll.dll")>
Private Declare Function SendMessage Lib "coredll.dll" Alias
"SendMessageA"
(ByVal hWnd As IntPtr, ByVal Msg As System.Int32, ByVal wParam As
System.Int32, ByVal lParam As System.Int32)

private sub SetWallpaper()
Dim strWhoAmI As String = ""
Dim registryKey As Microsoft.Win32.RegistryKey
Dim strValues() As String
try
registryKey = Microsoft.Win32.Registry.CurrentUser '.CurrentUser '
.GetValue("HKEY_CURRENT_USER\ControlPanel\Home")
strValues =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValueNames()
strWhoAmI =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValue("Wallpaper").ToString
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").SetValue("Wallpaper",
"\Windows\Guava bubbles.tsk")
strWhoAmI =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValue("Wallpaper").ToString
registryKey.Close()
SendMessage(HWND_BROADCAST, WM_WININICHANGE, SPI_SETDESKTOPWALLPAPER, 0)
Catch ex As Exception

End Try
End Sub

--
Deasun
Home Site: www.tirnaog.com
Check out: The Code Vault in my forums section.


Fabien said:
Hi,

Try to change this registry key : HKEY_CURRENT_USER\ControlPanel\Home
with your new image path and send a Windows Message to refresh the
today screen.
In C#, you must import the SendMessage function:

SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE,
SPI_SETDESKWALLPAPER, 0)

the import:
[DllImport("coredll.dll")]
private static extern int SendMessage(IntPtr hWnd, uint msg, int
wParam, int lParam);

BR

Fabien Decret (Device Application Development MVP)
Windows Embedded Consultant

ADENEO (ADESET)
http://www.adeneo.adetelgroup.com/ | http://fabdecret.blogspot.com/


Hello all,

Does anyone have a example of setting the today screens image to
another file?
I am looking to build my first PPC app and decide to do a wallpaper
changer.
Wow finding documentation on this is not easy!
I would like to do this in VB.net or C3.net.

Could anyone give me some pointers here?

Thanks
 
Sorry, meant to say that last time.
On trying to set the value;
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").SetValue("Wallpaper",
"\Windows\Guava bubbles.tsk")
--
Deasun
Home Site: www.tirnaog.com
Check out: The Code Vault in my forums section.


Paul G. Tobey said:
You get an error *WHEN*? What line of code is the problem?

Paul T.

Deasun said:
Thank you for your reply Fabien.
I tried what you said and I keep getting a Unautherizedaccess error!

Code I am currently trying is; [VB.net code.]

Public Shared HWND_BROADCAST As IntPtr = IntPtr.op_Explicit(&HFFFF)
Public Const WM_WININICHANGE = &H1A
Public Shared SPI_SETDESKTOPWALLPAPER As Integer = 20

'<DllImport("coredll.dll")>
Private Declare Function SendMessage Lib "coredll.dll" Alias
"SendMessageA"
(ByVal hWnd As IntPtr, ByVal Msg As System.Int32, ByVal wParam As
System.Int32, ByVal lParam As System.Int32)

private sub SetWallpaper()
Dim strWhoAmI As String = ""
Dim registryKey As Microsoft.Win32.RegistryKey
Dim strValues() As String
try
registryKey = Microsoft.Win32.Registry.CurrentUser '.CurrentUser '
.GetValue("HKEY_CURRENT_USER\ControlPanel\Home")
strValues =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValueNames()
strWhoAmI =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValue("Wallpaper").ToString
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").SetValue("Wallpaper",
"\Windows\Guava bubbles.tsk")
strWhoAmI =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValue("Wallpaper").ToString
registryKey.Close()
SendMessage(HWND_BROADCAST, WM_WININICHANGE, SPI_SETDESKTOPWALLPAPER, 0)
Catch ex As Exception

End Try
End Sub

--
Deasun
Home Site: www.tirnaog.com
Check out: The Code Vault in my forums section.


Fabien said:
Hi,

Try to change this registry key : HKEY_CURRENT_USER\ControlPanel\Home
with your new image path and send a Windows Message to refresh the
today screen.
In C#, you must import the SendMessage function:

SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE,
SPI_SETDESKWALLPAPER, 0)

the import:
[DllImport("coredll.dll")]
private static extern int SendMessage(IntPtr hWnd, uint msg, int
wParam, int lParam);

BR

Fabien Decret (Device Application Development MVP)
Windows Embedded Consultant

ADENEO (ADESET)
http://www.adeneo.adetelgroup.com/ | http://fabdecret.blogspot.com/


Hello all,

Does anyone have a example of setting the today screens image to
another file?
I am looking to build my first PPC app and decide to do a wallpaper
changer.
Wow finding documentation on this is not easy!
I would like to do this in VB.net or C3.net.

Could anyone give me some pointers here?

Thanks
 
At a guess, there's probably no key for one of those items that you're
chaining together, DeskTop, probably.

Paul T.

Deasun said:
Sorry, meant to say that last time.
On trying to set the value;
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").SetValue("Wallpaper",
"\Windows\Guava bubbles.tsk")
--
Deasun
Home Site: www.tirnaog.com
Check out: The Code Vault in my forums section.


Paul G. Tobey said:
You get an error *WHEN*? What line of code is the problem?

Paul T.

Deasun said:
Thank you for your reply Fabien.
I tried what you said and I keep getting a Unautherizedaccess error!

Code I am currently trying is; [VB.net code.]

Public Shared HWND_BROADCAST As IntPtr = IntPtr.op_Explicit(&HFFFF)
Public Const WM_WININICHANGE = &H1A
Public Shared SPI_SETDESKTOPWALLPAPER As Integer = 20

'<DllImport("coredll.dll")>
Private Declare Function SendMessage Lib "coredll.dll" Alias
"SendMessageA"
(ByVal hWnd As IntPtr, ByVal Msg As System.Int32, ByVal wParam As
System.Int32, ByVal lParam As System.Int32)

private sub SetWallpaper()
Dim strWhoAmI As String = ""
Dim registryKey As Microsoft.Win32.RegistryKey
Dim strValues() As String
try
registryKey = Microsoft.Win32.Registry.CurrentUser '.CurrentUser '
.GetValue("HKEY_CURRENT_USER\ControlPanel\Home")
strValues =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValueNames()
strWhoAmI =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValue("Wallpaper").ToString
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").SetValue("Wallpaper",
"\Windows\Guava bubbles.tsk")
strWhoAmI =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValue("Wallpaper").ToString
registryKey.Close()
SendMessage(HWND_BROADCAST, WM_WININICHANGE, SPI_SETDESKTOPWALLPAPER,
0)
Catch ex As Exception

End Try
End Sub

--
Deasun
Home Site: www.tirnaog.com
Check out: The Code Vault in my forums section.


:

Hi,

Try to change this registry key : HKEY_CURRENT_USER\ControlPanel\Home
with your new image path and send a Windows Message to refresh the
today screen.
In C#, you must import the SendMessage function:

SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE,
SPI_SETDESKWALLPAPER, 0)

the import:
[DllImport("coredll.dll")]
private static extern int SendMessage(IntPtr hWnd, uint msg, int
wParam, int lParam);

BR

Fabien Decret (Device Application Development MVP)
Windows Embedded Consultant

ADENEO (ADESET)
http://www.adeneo.adetelgroup.com/ | http://fabdecret.blogspot.com/


Hello all,

Does anyone have a example of setting the today screens image to
another file?
I am looking to build my first PPC app and decide to do a wallpaper
changer.
Wow finding documentation on this is not easy!
I would like to do this in VB.net or C3.net.

Could anyone give me some pointers here?

Thanks
 
Nope checked that already.

All those keys are in there. The Wallpaper had the value: default.2bp in it.
Some sort of PPC bitmap file.
Just cant overwrite it. :(

--
Deasun
Home Site: www.tirnaog.com
Check out: The Code Vault in my forums section.


Paul G. Tobey said:
At a guess, there's probably no key for one of those items that you're
chaining together, DeskTop, probably.

Paul T.

Deasun said:
Sorry, meant to say that last time.
On trying to set the value;
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").SetValue("Wallpaper",
"\Windows\Guava bubbles.tsk")
--
Deasun
Home Site: www.tirnaog.com
Check out: The Code Vault in my forums section.


Paul G. Tobey said:
You get an error *WHEN*? What line of code is the problem?

Paul T.

Thank you for your reply Fabien.
I tried what you said and I keep getting a Unautherizedaccess error!

Code I am currently trying is; [VB.net code.]

Public Shared HWND_BROADCAST As IntPtr = IntPtr.op_Explicit(&HFFFF)
Public Const WM_WININICHANGE = &H1A
Public Shared SPI_SETDESKTOPWALLPAPER As Integer = 20

'<DllImport("coredll.dll")>
Private Declare Function SendMessage Lib "coredll.dll" Alias
"SendMessageA"
(ByVal hWnd As IntPtr, ByVal Msg As System.Int32, ByVal wParam As
System.Int32, ByVal lParam As System.Int32)

private sub SetWallpaper()
Dim strWhoAmI As String = ""
Dim registryKey As Microsoft.Win32.RegistryKey
Dim strValues() As String
try
registryKey = Microsoft.Win32.Registry.CurrentUser '.CurrentUser '
.GetValue("HKEY_CURRENT_USER\ControlPanel\Home")
strValues =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValueNames()
strWhoAmI =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValue("Wallpaper").ToString
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").SetValue("Wallpaper",
"\Windows\Guava bubbles.tsk")
strWhoAmI =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValue("Wallpaper").ToString
registryKey.Close()
SendMessage(HWND_BROADCAST, WM_WININICHANGE, SPI_SETDESKTOPWALLPAPER,
0)
Catch ex As Exception

End Try
End Sub

--
Deasun
Home Site: www.tirnaog.com
Check out: The Code Vault in my forums section.


:

Hi,

Try to change this registry key : HKEY_CURRENT_USER\ControlPanel\Home
with your new image path and send a Windows Message to refresh the
today screen.
In C#, you must import the SendMessage function:

SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE,
SPI_SETDESKWALLPAPER, 0)

the import:
[DllImport("coredll.dll")]
private static extern int SendMessage(IntPtr hWnd, uint msg, int
wParam, int lParam);

BR

Fabien Decret (Device Application Development MVP)
Windows Embedded Consultant

ADENEO (ADESET)
http://www.adeneo.adetelgroup.com/ | http://fabdecret.blogspot.com/


Hello all,

Does anyone have a example of setting the today screens image to
another file?
I am looking to build my first PPC app and decide to do a wallpaper
changer.
Wow finding documentation on this is not easy!
I would like to do this in VB.net or C3.net.

Could anyone give me some pointers here?

Thanks
 
And this is what sort of device? Maybe that API is locked by the device
OEM...

Paul T.

Deasun said:
Nope checked that already.

All those keys are in there. The Wallpaper had the value: default.2bp in
it.
Some sort of PPC bitmap file.
Just cant overwrite it. :(

--
Deasun
Home Site: www.tirnaog.com
Check out: The Code Vault in my forums section.


Paul G. Tobey said:
At a guess, there's probably no key for one of those items that you're
chaining together, DeskTop, probably.

Paul T.

Deasun said:
Sorry, meant to say that last time.
On trying to set the value;
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").SetValue("Wallpaper",
"\Windows\Guava bubbles.tsk")
--
Deasun
Home Site: www.tirnaog.com
Check out: The Code Vault in my forums section.


:

You get an error *WHEN*? What line of code is the problem?

Paul T.

Thank you for your reply Fabien.
I tried what you said and I keep getting a Unautherizedaccess error!

Code I am currently trying is; [VB.net code.]

Public Shared HWND_BROADCAST As IntPtr = IntPtr.op_Explicit(&HFFFF)
Public Const WM_WININICHANGE = &H1A
Public Shared SPI_SETDESKTOPWALLPAPER As Integer = 20

'<DllImport("coredll.dll")>
Private Declare Function SendMessage Lib "coredll.dll" Alias
"SendMessageA"
(ByVal hWnd As IntPtr, ByVal Msg As System.Int32, ByVal wParam As
System.Int32, ByVal lParam As System.Int32)

private sub SetWallpaper()
Dim strWhoAmI As String = ""
Dim registryKey As Microsoft.Win32.RegistryKey
Dim strValues() As String
try
registryKey = Microsoft.Win32.Registry.CurrentUser '.CurrentUser '
.GetValue("HKEY_CURRENT_USER\ControlPanel\Home")
strValues =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValueNames()
strWhoAmI =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValue("Wallpaper").ToString
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").SetValue("Wallpaper",
"\Windows\Guava bubbles.tsk")
strWhoAmI =
registryKey.OpenSubKey("ControlPanel").OpenSubKey("DeskTop").GetValue("Wallpaper").ToString
registryKey.Close()
SendMessage(HWND_BROADCAST, WM_WININICHANGE,
SPI_SETDESKTOPWALLPAPER,
0)
Catch ex As Exception

End Try
End Sub

--
Deasun
Home Site: www.tirnaog.com
Check out: The Code Vault in my forums section.


:

Hi,

Try to change this registry key :
HKEY_CURRENT_USER\ControlPanel\Home
with your new image path and send a Windows Message to refresh the
today screen.
In C#, you must import the SendMessage function:

SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE,
SPI_SETDESKWALLPAPER, 0)

the import:
[DllImport("coredll.dll")]
private static extern int SendMessage(IntPtr hWnd, uint msg, int
wParam, int lParam);

BR

Fabien Decret (Device Application Development MVP)
Windows Embedded Consultant

ADENEO (ADESET)
http://www.adeneo.adetelgroup.com/ | http://fabdecret.blogspot.com/


Hello all,

Does anyone have a example of setting the today screens image to
another file?
I am looking to build my first PPC app and decide to do a
wallpaper
changer.
Wow finding documentation on this is not easy!
I would like to do this in VB.net or C3.net.

Could anyone give me some pointers here?

Thanks
 
The code below sets the today screen wallpaper in c# on windows mobile 5. It updates the background image on the today screen and the start menu. If the image is larger than 240 * 240 it gets cropped.

(tested on .NET Compact Framework 2.0, windows mobile 5, phone edition, pocket pc device: hp ipaq hw6940 / hw6945)

using System.Runtime.InteropServices;
using Microsoft.Win32;
....
[DllImport("coredll.dll")]
private static extern int SendMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
....
public const int HWND_BROADCAST = 0xffff;
public const int WM_WININICHANGE = 0x001A;

// Copy wallpaper file to windows directory
File.Copy(@"\My Documents\My Pictures\ImageFileName.jpg", @"\Windows\stwater_240_240.jpg", true);

// Update registry
Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Today", "Wall", "ImageFileName");

// Send message to refresh today screen
SendMessage((IntPtr)HWND_BROADCAST, WM_WININICHANGE, 0xF2, 0);

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 
Back
Top