Qt Code:
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <string>
  4. #include <Windows.h>
  5. using namespace std;
  6.  
  7. int main () {
  8. char *path = "C:\\Bliss.bmp";
  9. bool ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0,
  10. path,
  11. //NULL,
  12. //0);
  13. //SPIF_SENDCHANGE);
  14. //SPIF_SENDWININICHANGE);
  15. SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
  16. cout<<"the function returned "<<(ret ? "true" : "false");
  17. char* str = NULL; // function allocates the mem with LocalAlloc(), used with LocalFree()
  18. int msg_ret = FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | // let the function alloc string mem
  19. FORMAT_MESSAGE_FROM_SYSTEM | // use system message and not a passed one
  20. FORMAT_MESSAGE_IGNORE_INSERTS, // ignore and "inserts"
  21. NULL,
  22. GetLastError(), // get the error
  23. MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
  24. (CHAR*)&str,
  25. 0,
  26. NULL);
  27. cout<<"\n"<<str;
  28. cout<<"\n"<<path;
  29. return 0;
  30. }
To copy to clipboard, switch view to plain text mode 
That code actually works! Great!

But it does not work in QT.