alanis
alanis

Reputation: 11

How to change desktop background image on windows with c++?

How to change the desktop background image on Windows?

Right now, I found this solution:

SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, (PVOID*)desktop_image_file, SPIF_SENDCHANGE);

It works fine, but after a restart, the image is gone. How to save it permanently?

Upvotes: 1

Views: 248

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 595402

You need to include the SPIF_UPDATEINIFILE flag:

SPIF_UPDATEINIFILE
Writes the new system-wide parameter setting to the user profile.

SystemParametersInfoA(..., SPIF_SENDCHANGE | SPIF_UPDATEINIFILE);

Upvotes: 2

Related Questions