C++ 更换壁纸c++;我试过多种方法

C++ 更换壁纸c++;我试过多种方法,c++,C++,这不起作用^^^,并且ok.bmp在文件夹内 现在大多数构建都是Unicode的,所以请尝试使用Unicode字符串: string s = "C:\\ok.bmp"; SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)s.c_str(), SPIF_SENDCHANGE); (通过使用std::wstring::data(),您不需要强制转换) wstring ws = L"C:\\ok.bmp"

这不起作用^^^,并且ok.bmp在文件夹内

现在大多数构建都是Unicode的,所以请尝试使用Unicode字符串:

string s = "C:\\ok.bmp";
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)s.c_str(), SPIF_SENDCHANGE);
(通过使用std::wstring::data(),您不需要强制转换)

wstring ws = L"C:\\ok.bmp";
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, ws.data(), SPIF_SENDCHANGE);