#include <iostream>
#include <stdio.h>
#include <string>
#include <Windows.h>
using namespace std;
int main () {
char *path = "C:\\Bliss.bmp";
bool ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0,
path,
//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:\\Bliss.bmp";
bool ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0,
path,
//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
That code actually works! Great!
Bookmarks