Note that there are some explanatory texts on larger screens.

plurals
  1. POno suitable conversion function from "std::string" to "PVOID" exists
    primarykey
    data
    text
    <p>I am trying to use the SetParametersInfo function to change wallpapers.I would like to pass the filepath for the wallpaper as a variable, but whenever I try to do this, I get the error</p> <pre><code>Error: no suitable conversion function from "std::string" to "PVOID" exists </code></pre> <p>Here is the code I have thus far </p> <pre><code>#include &lt;windows.h&gt; #include &lt;stdio.h&gt; #include &lt;iostream&gt; #include &lt;string&gt; #pragma comment(lib, "user32.lib") using namespace std; #define _TEXT(x) L##x void main(){ string input =""; cout &lt;&lt; "Enter the filepath\n"; getline(cin, input); BOOL success = SystemParametersInfo( SPI_SETDESKWALLPAPER, //iuAction 0, //uiParam input, //pvParam SPIF_UPDATEINIFILE //fWinIni ); if (success){ printf("Success!\n"); }else printf("Failure =(\n"); } </code></pre> <p>Do you guys have any suggestions for what I can do? I have looked all over to find a solution and haven't been able to find one. Perhaps I am not searching for the right terms.</p> <p>Extra info: I am running Windows 7 and using Visual Studio 2010 Ultimate. </p> <p><strong>Edit:</strong> I finally got it to work. I had to change the "Character Set" setting to "Not Set" then it worked fine. Here is the updated code:</p> <pre><code>#include &lt;windows.h&gt; #include &lt;stdio.h&gt; #include &lt;iostream&gt; #include &lt;string&gt; #pragma comment(lib, "user32.lib") using namespace std; void main(){ string input =""; cout &lt;&lt; "Enter the filepath\n"; getline(cin, input); BOOL success = SystemParametersInfo( SPI_SETDESKWALLPAPER, //iuAction 0, //uiParam (PVOID) input.c_str(), //pvParam SPIF_UPDATEINIFILE //fWinIni ); if (success){ printf("Success!\n"); }else{ printf("Failure =(\n "); cout &lt;&lt; input &lt;&lt; "\n"; cout &lt;&lt; (PVOID) input.c_str()&lt;&lt; "\n"; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload