title: Change wallpaper programmatically using c++ and windows api
body: <p>I've been trying to write an application, using Qt and mingw32, to download images and set them as the background Wallpaper. I have read several articles online about how to do this, in VB and C#, and to some extent how to do it in c++. I am currently calling the <code>SystemParametersInfo</code> with what seems to be all the correct arguments (no compiler errors) and it fails. No great crash of cymbals, just a <code>0</code> returned. <code>GetLastError()</code> returns an equally enlightening <code>0</code>.</p>
  
  <p>Below is the code I am using (In a slightly modified form, so you do not have to view the object internals).</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;iostream&gt;
  #include &lt;QString&gt;
  
  void setWall()
  {
      QString filepath = "C:\\Documents and Settings\\Owner\\My Documents\\Wallpapers\\wallpaper.png";
      char path[150];
      strcpy(path, currentFilePath.toStdString().c_str());
      char *pathp;
      pathp = path;
  
      cout &lt;&lt; path;
  
      int result;
      result = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, pathp, SPIF_UPDATEINIFILE);
  
      if (result)
      {
          cout &lt;&lt; "Wallpaper set";
      }
      else
      {
          cout &lt;&lt; "Wallpaper not set";
          cout &lt;&lt; "SPI returned" &lt;&lt; result;
      }
  }
  </code></pre>