I’m trying to use CreateProcess in order to run a file that is located on the user’s Program Files directory, so I’m trying to use CSIDL_PROGRAM_FILESX86 since that specific program will always be on the (x86) folder.
My problem is that I can’t get it to work, for some reason I cannot find any example of how to use createprocess and CSIDL_PROGRAM_FILESX86
Can you direct me to such example? Maybe I should use a different function?
EDIT:
This is my current code:
wchar_t* localAppData = 0;
SHGetFolderPath(NULL, CSIDL_PROGRAM_FILESX86, 0, NULL, &localAppData);
wstringstream ss;
ss << localAppData << L"/MyApp/MyExe.exe";
CreateProcess(static_cast<void*>(localAppData));
I’m getting this for teh SHGetFolderPath:
cannot convert parameter 5 from wchar_t ** to LPWSTR
Also, even though I’ve included sstream in the headers, I’m getting these errors:
'wstringstream' : undeclared identifier
Note: I’m using SHGetFolderPath as I need this to work on both XP and Vista/7
Any ideas?
The problem is the C style string handling that you need for the Windows API:
Also, note that only
CSIDL_PROGRAM_FILESis supported withSHGetFolderPath.