Ok, I took a few steps back and made a single c++ file that only changes the wallpaper, no GUI.
#include <iostream>
#include <stdio.h>
#include <string>
#include <Windows.h>
using namespace std;
int main () {
char *path = "C:\\WINDOWS\\Web\\Wallpaper\\Windows XP.jpg";
string *pathStr = new string(path);
bool ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0,
pathStr,
//NULL,
//0);
//SPIF_SENDCHANGE);
//SPIF_SENDWININICHANGE);
SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
cout<<"the function returned "<<(ret ? "true" : "false");
char* str = NULL; // function allocates the mem with LocalAlloc(), used with LocalFree()
int msg_ret = FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | // let the function alloc string mem
FORMAT_MESSAGE_FROM_SYSTEM | // use system message and not a passed one
FORMAT_MESSAGE_IGNORE_INSERTS, // ignore and "inserts"
NULL,
GetLastError(), // get the error
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
(CHAR*)&str,
0,
NULL);
cout<<"\n"<<str;
cout<<"\n"<<path;
return 0;
}
#include <iostream>
#include <stdio.h>
#include <string>
#include <Windows.h>
using namespace std;
int main () {
char *path = "C:\\WINDOWS\\Web\\Wallpaper\\Windows XP.jpg";
string *pathStr = new string(path);
bool ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0,
pathStr,
//NULL,
//0);
//SPIF_SENDCHANGE);
//SPIF_SENDWININICHANGE);
SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
cout<<"the function returned "<<(ret ? "true" : "false");
char* str = NULL; // function allocates the mem with LocalAlloc(), used with LocalFree()
int msg_ret = FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | // let the function alloc string mem
FORMAT_MESSAGE_FROM_SYSTEM | // use system message and not a passed one
FORMAT_MESSAGE_IGNORE_INSERTS, // ignore and "inserts"
NULL,
GetLastError(), // get the error
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
(CHAR*)&str,
0,
NULL);
cout<<"\n"<<str;
cout<<"\n"<<path;
return 0;
}
To copy to clipboard, switch view to plain text mode
at it returns
the function returned false
The system cannot find the file specified.
C:\WINDOWS\Web\Wallpaper\Windows XP.jpg
the function returned false
The system cannot find the file specified.
C:\WINDOWS\Web\Wallpaper\Windows XP.jpg
To copy to clipboard, switch view to plain text mode
But the file exists. I have also tried with bmp files, getting the same error message.
Bookmarks