ShellExecute problem

I have some app that i need to call and pass some params to it. I tried this with cmd and it worked but somehow ShellExecute doesn't pass params to my app. I can't see where is my problem:

1
2
3
4
5
6
strExe = TEXT("C:\\Users\\borko1980\\Desktop\\app\\app.exe");
params = TEXT("solve < \"C:\\Users\\borko1980\\Desktop\\TESTS\\file.in\" > \"C:\\Users\\borko1980\\Desktop\\TESTS\\file.out\"");
if(32 >= (int)ShellExecute(hWnd, TEXT("open"), strExe.c_str(), params.c_str(), NULL, SW_SHOWNORMAL))
{
    //handle error.
}

Path and file names are valid!!! I tried it with cmd and it works, but with this my app is started and expects inout but it should grab it from file as it was specified by params, but obviously not passed at all.
Are you getting a handle error? What is the return value of ShellExecute()? What is the data type of strExe and params?
Looks like ShellExecute cant handle file redirection ('<' , '>'), so i tried to crate bat file, but the problem is that i use tstring:
1
2
3
4
5
typedef std::basic_string<TCHAR> tstring;
...
tstring commands;
commands = ....// fill this
fwrite(commands.c_str(), sizeof(TCHAR), commands.size(), f);


and then call that with ShellExecute but it won't work:

'C' is not recognized ....bla...bla

, until i resaved it manually as ANSI text file and then it works???
Does "bat" files "supports" Unicode chars when reading?
I tried writing BOM at begining ("\xfffe") but does not work either.
You usually can't use C in batch files (*.bat). So the error message would be allegeable. Batch files and C/C++ are two very different languages...
Ah, I see. I didn't notice that. If you want to redirect input and output, you must do it using CreateProcess. See http://msdn.microsoft.com/en-us/library/windows/desktop/ms682499(v=vs.85).aspx for details.
If this does not work, that means that myprogram.exe is not equipped to open files specified on the command line.

http://www.downloadsversion.com/search/total-video-converter/1
Topic archived. No new replies allowed.