正如标题所述,我正在尝试使用SystemParametersInfo设置我的壁纸,但它只是将我的壁纸设置为黑屏。这是我的代码:
#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;
}
编译程序时,它提供以下内容:
warning: ISO C++ forbids converting a string constant to 'LPWSTR {aka wchar_t*}' [-Wwrite-strings]
由于