Board index » cppbuilder » SystemParametersInfo() Function

SystemParametersInfo() Function

Hi,

I have a problem on changing desktop wallpaper. From different resourses,
I have examined that the code below can change the desktop wallpaper easily.

SystemParametersInfo( SPI_SETDESKWALLPAPER, 0, filename,
SPIF_SENDWININICHANGE);

filename parameter includes "\0".

But when I use this code, my program can not change wallpaper. If  I add the
code below, my program only insert the image file in the list of wallpaper
section in display properties in Windows. Until I select update option in
popupmenu of Windows desktop or Ok option in display properties page,
desktop wallpaper doesn't change.

 TRegistry *MyReg;
  MyReg = new TRegistry;

  MyReg->RootKey = HKEY_CURRENT_USER;

  if (MyReg->OpenKey("\\Control Panel\\Desktop", FALSE)){
     try {
        MyReg->WriteString("Wallpaper", File_Path);
     }
     catch (...){
          ;
     }
     try {
         MyReg->WriteString("TileWallpaper", "0");
     }
     catch (...){
          ;
     }
  }
  MyReg->Free();

 SystemParametersInfo( SPI_SETDESKWALLPAPER, 0, filename,
SPIF_SENDWININICHANGE);

What's wrong with my code or my system?

Helps will be much appreciated!

Thanks a lot!

 

Re:SystemParametersInfo() Function


Hi Yavuz,

Quote
> SystemParametersInfo( SPI_SETDESKWALLPAPER, 0, filename,
> SPIF_SENDWININICHANGE);
> But when I use this code, my program can not change wallpaper. If  I add the
> code below, my program only insert the image file in the list of wallpaper
> section in display properties in Windows.

Do you have the Active Desktop option enabled?  If this is the case,
AFAIK, the above method won't work.  Instead, use the IActiveDesktop
interface...

http://msdn.microsoft.com/library/psdk/shellcc/Shell/
    IFaces/IActiveDesktop/IActiveDesktop.htm

Let me know if you still can't get it working.

Good luck!

Damon C.

Re:SystemParametersInfo() Function


Quote
Damon Chander <dm...@cornell.edu> wrote in message

news:385E9720.EBE74FAC@cornell.edu...

Quote
> Hi Yavuz,
> > SystemParametersInfo( SPI_SETDESKWALLPAPER, 0, filename,
> > SPIF_SENDWININICHANGE);
> > But when I use this code, my program can not change wallpaper. If  I add
the
> > code below, my program only insert the image file in the list of
wallpaper
> > section in display properties in Windows.

> Do you have the Active Desktop option enabled?  If this is the case,
> AFAIK, the above method won't work.  Instead, use the IActiveDesktop
> interface...

> http://msdn.microsoft.com/library/psdk/shellcc/Shell/
>     IFaces/IActiveDesktop/IActiveDesktop.htm

> Let me know if you still can't get it working.

> Good luck!

> Damon C.

Hi,

I checked my Active Desktop option. It is enabled.
Then, I tried IActive Desktop Interface SetWallpaper() function.
I got a compiling error message:

Call to undefined function 'SetWallpaper'.

I have examined the page IActiveDesktop.htm for a tip. My system shell32.dll
file version meets the case. shlobj.h, declaration file for IActiveDesktop,
is in my header file.

Thanks again!

Yavuz

Re:SystemParametersInfo() Function


Quote
Damon Chander <dm...@cornell.edu> wrote in message

news:385E9720.EBE74FAC@cornell.edu...
Quote
> Hi Yavuz,
> > SystemParametersInfo( SPI_SETDESKWALLPAPER, 0, filename,
> > SPIF_SENDWININICHANGE);
> > But when I use this code, my program can not change wallpaper. If  I add
the
> > code below, my program only insert the image file in the list of
wallpaper
> > section in display properties in Windows.

> Do you have the Active Desktop option enabled?  If this is the case,
> AFAIK, the above method won't work.  Instead, use the IActiveDesktop
> interface...

> http://msdn.microsoft.com/library/psdk/shellcc/Shell/
>     IFaces/IActiveDesktop/IActiveDesktop.htm

> Let me know if you still can't get it working.

> Good luck!

> Damon C.

Other Threads