WinAPI: ShellExecute. Transmission parameters of the running application?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
2 views
Good evening (morning/afternoon/night). Write a program using WinAPI. In particular, the function ShellExecute. This programme is a console application that passes the parameters (output STDERR stream to a text file).

At the command prompt, write this:
program.exe -2>err.txt


In your code you write:
ShellExecute(handle, 'open', 'program.exe', '-2>err.txt', nil, SW_SHOW);


Without parameters ('-2>err.txt') the program is run, the error displays in the console. And with options also shows in the console, although you need to file.

What is the error? How can you do better?
by | 2 views

6 Answers

0 like 0 dislike
Redirect I / o is NOT a command-line parameters.
Try experimenting with the CreateProcess, the lpStartupInfo parameter can be useful.
by
0 like 0 dislike
Try this:
ShellExecute(handle, 'open', 'cmd.exe', '/C program.exe > err.txt', nil, SW_SHOW);
by
0 like 0 dislike
Exactly as said by the previous speaker.
Open the file using CreateFile with parameter SECURITY_ATTRIBUTES.bInheritHandle = TRUE and do CreateProcess with bInheritHandles = TRUE and lpStartupInfo.dwFlags |= STARTF_USESTDHANDLES, lpStartupInfo.hStdError = hFile.
by
0 like 0 dislike
> ShellExecute(handle, 'program.exe', '-2>err.txt', nil, SW_SHOW);
Need another argument between the handle and 'program.exe'.
\r
Maybe use ShellExecute instead of WinExec?
by
0 like 0 dislike
Here already with this question struggled: http://www.wasm.ru/forum/viewtopic.php?id=8962
by
0 like 0 dislike
Thank you all for the advice. First, did the crutch: I wrote a batch file with the necessary parameters and have it called via ShellExecute. Then ordered via CreateProcess, it worked. Thank you all, all positive :)
by

Related questions

0 like 0 dislike
1 answer
asked May 21, 2019 by 4ainik
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
27,913 users