PDA

Click to See Complete Forum and Search --> : Set Desktop Wallpaper???


hellswraith
Jun 7th, 2002, 12:17 PM
Anyone know how to set the Desktop Wallpaper on a users machine through .Net code yet?

I tried this (a long shot):
Microsoft.Win32.UserPreferenceCategory.Desktop = viewAreaPic.Image;

Didn't work though. Maybe someone has done this or can give me a kick in the right direction...

cim3
Jun 10th, 2002, 09:21 AM
This works.

Dim key As RegistryKey = Registry.CurrentUser.OpenSubKey("Control Panel", True)

Try
key = key.OpenSubKey("Desktop", True)

key.SetValue("Wallpaper", "YOUR IMAGE")
Catch ex As Exception

End Try

hellswraith
Jun 10th, 2002, 06:53 PM
cim3, thanks for the reply, but that didn't work on my computer.

I switch the code to C# syntax it is here:

RegistryKey key = Registry.CurrentUser.OpenSubKey("Control Panel", true);

try
{
key = key.OpenSubKey("Desktop", true);

key.SetValue("Wallpaper", thumbPanel.CurrentThumbPath.ToString());
}
catch
{
// Something went wrong.
}