ShellExecute的问题 [英] problem with ShellExecute

查看:175
本文介绍了ShellExecute的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我尝试使用以下代码而它没有,我认为问题是">"字符。如果我使用System()命令,没有问题,但不好的是,b
显示控制台。谢谢。 (c ++)

Hi. I try to work the following code and it does not, I think the problem is the ">" character. If I use the System () command, there is no problem, but the bad thing is that
shows the console. Thank you. (c++)

char    comando [] =" c: \\Constructor \\JPG \\cjpeg.exe" ;;

char  comando[] = "c:\\Constructor\\JPG\\cjpeg.exe";

char argumentos [] =" c:\\Constructor \ \ TEMP \\FOTO-001_.bmp> k:\\1a \\FOTO-002.jpg" ;;
$


ShellExecute(NULL,"open",comando,argumentos,NULL,SW_HIDE );

char argumentos[] = "c:\\Constructor\\TEMP\\FOTO-001_.bmp > k:\\1a\\FOTO-002.jpg";

ShellExecute(NULL, "open", comando, argumentos, NULL, SW_HIDE);




推荐答案

ShellExecute调用与系统不同。

That ShellExecute call doesn't do the same thing as system.

什么:

system("command");

基本上将其翻译为:

cmd / c" command"

cmd /c "command"

基本上它通过命令处理器(cmd.exe)运行它。这将导致命令处理器解释>作为重定向。

Basically it runs it through the command processor (cmd.exe). This will cause the command processor to interpret the > as a redirection.

但是,ShellExecute根本不会通过命令处理器。那么>传递给cjpeg可执行文件的命令行。

However, ShellExecute doesn't go through the command processor at all. So the > gets passed through to the cjpeg executable's command line.

如果你想获得与系统相同的东西,那么就不能使用ShellExecute。您需要使用CreateProcess并将hStdOutput句柄设置为该文件(您可以使用CreateFile打开它。)

If you want to get the same thing as system, then you can't use ShellExecute. You need to use CreateProcess and set the hStdOutput handle to the file (you can open this with CreateFile).

或者您可以使用cmd.exe作为命令,并且:

Or you can use cmd.exe for the command and:

" / cc:\\Constructor \\ JPG \\ cjpeg.exe c:\\Constructor \\TEMP \\\ \\ FOTO-001_.bmp> k:\\1a \\FOTO-002.jpg "

"/c c:\\Constructor\\JPG\\cjpeg.exe c:\\Constructor\\TEMP\\FOTO-001_.bmp > k:\\1a\\FOTO-002.jpg"

参数。


这篇关于ShellExecute的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆