PDA

Click to See Complete Forum and Search --> : Setting Background


Optic
Apr 21st, 2001, 09:51 AM
I need the api for setting the windows background to the image found in an image box. I am running windows 98. Any help would be appreciated.

Megatron
Apr 21st, 2001, 11:24 AM
It's found in the registry in the folloying path:

HKEY_CURRENT_USER\Control Panal\Desktop\WallPaper

Megatron
Apr 21st, 2001, 11:27 AM
Add to a Module.

Declare Function RegCloseKey Lib "advapi32.dll" (ByVal HKEY As Long) As Long
Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal HKEY As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal HKEY As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Public Const HKEY_CURRENT_USER = &H80000001

Public Sub SaveSettingEx(HKEY As Long, sPath As String, sValue As String, sData As String)
Dim KeyHand As Long
Call RegCreateKey(HKEY, sPath, KeyHand)
Call RegSetValueEx(KeyHand&, sValue, 0, REG_SZ, ByVal sData, Len(sData))
Call RegCloseKey(KeyHand&)
End Sub


Usage:

'Excute this to change wall paper.
SaveSettingEx HKEY_CURRENT_USER, "Control Panal\Desktop", "Wallpaper", "C:\MyFile.bmp"