简体   繁体   English

ProcessStartInfo.UseShellExecute有什么大不了的?

[英]What's the big deal with ProcessStartInfo.UseShellExecute?

How will ProcessStartInfo.UseShellExecute affect my running process? ProcessStartInfo.UseShellExecute将如何影响我的运行进程?

Do i need special permissions from UAC to UseShellExecute? 我是否需要UAC对UseShellExecute的特殊权限?

Will it run on diffrent user? 它会在不同的用户上运行吗?

Will it give me new permissions? 它会给我新的权限吗?

Windows has two distinct api functions to get a process started. Windows有两个不同的api函数来启动进程。 The low-level one is CreateProcess(), it directly maps to a native api function. 低级的是CreateProcess(),它直接映射到本机api函数。 And there's ShellExecuteEx(), a function that's implemented by the shell (Explorer). 还有ShellExecuteEx(),这是一个由shell(Explorer)实现的函数。 It has a much higher level of abstraction. 它具有更高的抽象级别。

They are very different capabilities and that's something you see back in the documentation for ProcessStartInfo. 它们是非常不同的功能,您可以在ProcessStartInfo的文档中看到这些功能。 CreateProcess() can only start executable files but it has good support to control a console mode program, including the ability to redirect I/O and control the appearance of the console window. CreateProcess()只能启动可执行文件,但它有很好的支持来控制控制台模式程序,包括重定向I / O和控制控制台窗口外观的能力。 ShellExecuteEx() takes advantage of the capabilities added by the shell, file associations being the big one, so you can start the executable that's registered for a specific filename extension. ShellExecuteEx()利用shell添加的功能,文件关联是最重要的,因此您可以启动为特定文件扩展名注册的可执行文件。

Both api functions have options to affect the way the process execute. 两个api函数都有选项来影响进程的执行方式。 You'll see a close correlation between the properties of the ProcessStartInfo class and the Process Creation Flags supported by CreateProcess and the fields in the SHELLEXECUTEINFO structure that ShellExecuteEx() uses. 您将看到ProcessStartInfo类的属性与CreateProcess支持的Process Creation Flags以及ShellExecuteEx()使用的SHELLEXECUTEINFO结构中的字段之间存在密切关联。 But these features don't overlap so that's why you need to tinker with UseShellExecute. 但这些功能不重叠,这就是为什么你需要修改UseShellExecute。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM