When I use ShellExecuteEx with such a command "-unused parameter -action capturescreenshot -filename C:\\ATDK\\Screenshots\\abcd.jbg"
everything works fine and Executor.exe starts with char* argv[]
having all the approx. 9 parameters. But when the command has for a couple symbols more, e.g. file name is "abc...xyz.jpg" then that process has argc == 1 and the command is empty. So the command is OK before sending to ShellExecute After I changed that to the ShellExecute, not Ex, it works! Command can be very long, and it's passed successfully. Can anybody explain what is the difference? Here's a code with the SHELLEXECUTEINFO I filled up.
std::wstringstream wss;
wss << L"-unused" << " " // added because we need to pass some info as 0 parameter
<< L"parameter" << " " // added because EU parser sucks
<< L"-action" << " "
<< L"capturescreenshot" << " "
<< L"-filename" << " "
<< L"C:\\ATDK\\Screenshots\\abc.jpg";
SHELLEXECUTEINFO shell_info;
ZeroMemory(&shell_info, sizeof(shell_info));
shell_info.cbSize = sizeof(SHELLEXECUTEINFO);
shell_info.fMask = SEE_MASK_ASYNCOK | SEE_MASK_NO_CONSOLE;
shell_info.hwnd = NULL;
shell_info.lpVerb = NULL;
shell_info.lpFile = L"C:/ATDK/Executor";
shell_info.lpParameters = (LPCWSTR)wss.str().c_str();
shell_info.lpDirectory = NULL;
shell_info.nShow = SW_MINIMIZE;
shell_info.hInstApp = NULL;
// 1
ShellExecuteEx(&shell_info);
// this sucks,
// GetLastError returns err code 2147483658,
//FormatMessage returns The data necessary to complete this operation is not yet available
// 2
ShellExecute(NULL, NULL, L"C:/ATDK/Executor", (LPCWSTR)wss.str().c_str(), NULL, NULL);
// OK!