#include <iostream>
#include <windows.h>
using namespace std;
int main(){
LPWSTR test = L"C:/aizen.png";
int result = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, test, SPIF_UPDATEINIFILE);
if(result)
cout << "Wallpaper set!";
else
cout << "NOOOOO!" << result;
cin >> result;
return 0;
}
Very simple code, but result returns 0. What am I doing wrong?
Do what the documentation says, and call
GetLastErrorto find out the reason behind the error.Some possible causes spring to mind:
SystemParametersInfodoes not like forward slashes as separators.Really, the list is endless. So let the system tell you.
Note that the documentation says:
But this is a great big fat lie. It’s trivially easy to call the function, pass
SPI_SETDESKWALLPAPER, and receiveFALSEin return.