C++ SHGetFolderPath issue
<p>I'm trying to get the local 'Program files' dir path and append some extra path to it and simply execute it. Can't get it to work properly..</p>

<p>This is my current code:</p>

<pre><code>wchar_t* localAppData = 0;
SHGetFolderPath(NULL, CSIDL_PROGRAM_FILESX86, 0, NULL, &amp;localAppData);

wstringstream ss;
ss &lt;&lt; localAppData &lt;&lt; L"/MyApp/MyExe.exe";

CreateProcess(static_cast&lt;void*&gt;(localAppData));
</code></pre>

<p>I'm getting this for teh SHGetFolderPath:</p>

<pre><code>cannot convert parameter 5 from wchar_t ** to LPWSTR
</code></pre>

<p>Also, even though I've included sstream in the headers, I'm getting these errors:</p>

<pre><code>'wstringstream' : undeclared identifier
</code></pre>

<p>Note: I'm using SHGetFolderPath as I need this to work on both XP and Vista/7</p>

<p><strong>EDIT:</strong></p>

<p>Had a mistake in the code above, I was trying to run <code>localAppData</code> which is the path to the 'Program Files' directory, instead of running the entire path.</p>

<p>But when I try using the <code>ss</code> var instead of <code>localAppData</code> var in the <code>CreateProcess</code> function, I'm getting an error about using the wrong type of var (need to be using LPCWSTR).</p>

<p>But when I try this, doesn't work as well.. No error but application is not running, what am I missing?</p>

<pre><code>wchar_t localAppData[MAX_PATH];
STARTUPINFO sInfo;
PROCESS_INFORMATION pInfo;
SHGetFolderPath(NULL, CSIDL_PROGRAM_FILESX86, 0, NULL, localAppData);

std::wstringstream ss;
ss &lt;&lt; localAppData &lt;&lt; L"/MyApp/MyExe.exe";
LPCWSTR str = ss.str().c_str();
CreateProcess(str, NULL,NULL, NULL,FALSE,NULL,NULL,NULL,&amp;sInfo,&amp;pInfo);
return str;
</code></pre>

<p>Any ideas?</p>
