As the title states, I'm trying to use SystemParametersInfo to set my wallpaper, but it's just setting my wallpaper to a black screen. Here is my code:
#include <windows.h>
#include <iostream>
void setWall()
{
LPWSTR path = L"D:\\Wallpaper.png";
int result;
result = SystemParametersInfo(
SPI_SETDESKWALLPAPER,
0,
path,
SPIF_UPDATEINFILE);
std::cout<<result<<std::endl;
if (result)
{
std::cout << "Wallpaper set";
}
else
{
std::cout << "Wallpaper not set";
std::cout << "SPI returned" << result;
}
}
int main()
{
setWall();
return 0;
}
When compiling the program it gives the following:
warning: ISO C++ forbids converting a string constant to 'LPWSTR {aka wchar_t*}' [-Wwrite-strings]
Thanks