[英]CreateProcess and ShellExecute differences
What are the main differences between the two? 两者之间的主要区别是什么? I'm willing to run only another EXE from my (C++) application. 我愿意从我的(C ++)应用程序中只运行另一个EXE。 Are there any differences when inheriting environments, security features etc? 继承环境,安全功能等时是否有任何差异?
The main difference between CreateProcess
and ShellExecute
is the following: CreateProcess
is more oriented on low level and ShellExec
on the high user lever which see the user in explorer. CreateProcess
和ShellExecute
之间的主要区别如下: CreateProcess
更ShellExec
低级别,而高级用户杠杆上的ShellExec
更适合在资源管理器中查看用户。
For example using of CreateProcess
one can use command line which length is more as MAX_PATH
. 例如,使用CreateProcess
可以使用长度多于MAX_PATH
命令行。 It has 32,768 characters restriction. 它有32,768个字符的限制。 You can also use CreateProcess
to start program (if you have enough permissions) on another windows desktop like on the Logon Screen. 您还可以使用CreateProcess
在另一个Windows桌面上启动程序(如果您有足够的权限),如登录屏幕上。
Another example. 另一个例子。 You can use ShellExecute
to start Control Panel or open any program which existed on the computer for editing of JPG filed for example. 例如,您可以使用ShellExecute
启动控制面板或打开计算机上存在的任何程序以编辑JPG。 So you works with ShellExecute
close to the corresponding actions in the Windows Explorer. 因此,您可以使用ShellExecute
接近Windows资源管理器中的相应操作。
The main difference is in flexibility. 主要区别在于灵活性。 ShellExecute
is easier to use, but doesn't have a lot of flexibility. ShellExecute
更易于使用,但没有很大的灵活性。 CreateProcess
is a pain to use, but lets you do anything. CreateProcess
很难用,但可以让你做任何事情。
Just for example, with CreateProcess
, you can specify handles (pipes or files) to use for the standard input/output/error streams in the child. 例如,使用CreateProcess
,您可以指定用于子项中标准输入/输出/错误流的句柄(管道或文件)。 ShellExecute
doesn't give you want way to do that. ShellExecute
不会让你想要这样做。
It's probably also worth noting that although ShellExecute
can be used to start an executable directly, its primary intent is to "execute" document files -- for example, tell it to "execute" a "whatever.html", and it starts up your default web browser and loads the specified HTML file into it. 值得注意的是,尽管可以使用ShellExecute
直接启动可执行文件,但它的主要目的是“执行”文档文件 - 例如,告诉它“执行”“whatever.html”,它会启动你的默认Web浏览器并将指定的HTML文件加载到其中。 You can do that using CreateProcess
as well, but to do it, you (normally) start by calling FindExecutable
to find the program associated with the data file in question, then execute that passing your data file as a parameter. 你也可以使用CreateProcess
来做到这一点,但为了做到这一点,你(通常)通过调用FindExecutable
来查找与相关数据文件相关联的程序,然后执行将数据文件作为参数传递。
CreateProcess
返回已启动进程的句柄和id,它是PROCESS_INFORMATION
结构中的主线程
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.