Click to See Complete Forum and Search --> : Changing Registry without rebooting
varundua
February 2nd, 2009, 04:40 AM
Hi all
I am changing registry through the WinAPI functions, though the registry changes but there is no effect on the setings for eg. I change the wallpaper and put an html page on the waallpaper using the registry but nothing happens.
plz help
thnx
ovidiucucu
February 2nd, 2009, 05:21 AM
Instead of changing registry values, call SystemParametersInfo(SPI_SETDESKWALLPAPER... (http://msdn.microsoft.com/en-us/library/ms724947.aspx) to change the desktop wallpaper.
varundua
February 2nd, 2009, 05:28 AM
thanx
i have done that but that only allows *.bmp files but i require other type of files too that is .jpeg and most importantly .html pages
ovidiucucu
February 2nd, 2009, 06:37 AM
After changing the registry values you can try to call
PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETDESKWALLPAPER, 0);
However, that may not use because I have observed that
HKEY_CURRENT_USER\Control Panel\Desktop\"Wallpaper"
has to point to a bitmap (.bmp) file.
Other applications which change the desktop wallpaper, first convert other formats (jpeg, png, and so on) into bmp, store it somewhere, then set the wallpaper image.
I have never put a HTML on the desktop, maybe it's possible, but for sure it's another way than setting the wallpaper image.
varundua
February 2nd, 2009, 06:46 AM
After changing the registry values you can try to call
PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETDESKWALLPAPER, 0);
However, that may not use because I have observed that
HKEY_CURRENT_USER\Control Panel\Desktop\"Wallpaper"
has to point to a bitmap (.bmp) file.
Other applications which change the desktop wallpaper, first convert other formats (jpeg, png, and so on) into bmp, store it somewhere, then set the wallpaper image.
I have never put a HTML on the desktop, maybe it's possible, but for sure it's another way than setting the wallpaper image.
To put an html wallpaper the key to be used is
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Desktop\General]
Wallpaper
putting the value of wallpaper as the name of the html file does that but only after logging off
that is changing the registry itself won't work since the changes are not effected immediately.
what has to be done in addition to changing the registry?
ovidiucucu
February 4th, 2009, 04:16 AM
Just as a workaround
Using Spy++ for whatever top-level window and then setting the desktop html page from "Display Properties/Desktop" we can observe that WM_SETTINGCHANGE is sent.
Have you tried to broadcast this message as I suggested earlier?
Marc G
February 4th, 2009, 08:10 AM
Try:
DWORD dwReturnValue;
::SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, (LPARAM)_T("Desktop"), SMTO_ABORTIFHUNG | SMTO_BLOCK, 2000, &dwReturnValue);
A variant on what Ovidiu posted before.
Also, did you try the IActiveDesktop interface?
USES_CONVERSION;
HRESULT hr;
IActiveDesktop *pActiveDesktop = NULL;
//Create an instance of the Active Desktop
hr = CoCreateInstance(CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER,
IID_IActiveDesktop, (void**)&pActiveDesktop);
WALLPAPEROPT wallpaperopt = {0};
wallpaperopt.dwSize = sizeof(WALLPAPEROPT);
wallpaperopt.dwStyle = WPSTYLE_TILE;
pActiveDesktop->SetWallpaperOptions(&wallpaperopt, NULL);
LPWSTR wstrImg = T2W(pszFile);
pActiveDesktop->SetWallpaper(wstrImg, NULL);
pActiveDesktop->ApplyChanges(AD_APPLY_ALL);
pActiveDesktop->Release();
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.