MSDN中说了这么一句: SHELLEXECUTEINFO Handle to the newly started application. This member is set on return and is always NULL unless fMask is set to SEE_MASK_NOCLOSEPROCESS. Even if fMask is set to SEE_MASK_NOCLOSEPROCESS, hProcess will be NULL if no process was launched. For example, if a document to be launched is a URL and an instance of Microsoft® Internet Explorer is already running, it will display the document. No new process is launched, and hProcess will be NULL.
额, 调用了过没用,按说CreateProcess以后,Wait应该阻塞在那的吧,但是,直接就越过去了。那句柄就是失效了呗? 因为比如你用UE打开了个txt文件,此时UE是一个进程,再打开一个txt呢,这时候UE中只是增加了一页,虽然CreateProcess中有那个进程句柄啊,但是那个句柄是无效的啊。
SHELLEXECUTEINFO
Handle to the newly started application. This member is set on return and is always NULL unless fMask is set to SEE_MASK_NOCLOSEPROCESS. Even if fMask is set to SEE_MASK_NOCLOSEPROCESS, hProcess will be NULL if no process was launched. For example, if a document to be launched is a URL and an instance of Microsoft® Internet Explorer is already running, it will display the document. No new process is launched, and hProcess will be NULL.
额, 调用了过没用,按说CreateProcess以后,Wait应该阻塞在那的吧,但是,直接就越过去了。那句柄就是失效了呗? 因为比如你用UE打开了个txt文件,此时UE是一个进程,再打开一个txt呢,这时候UE中只是增加了一页,虽然CreateProcess中有那个进程句柄啊,但是那个句柄是无效的啊。
你还能用CreateProcess打开txt? 打开文件关联程序不是ShellExecute干的事吗?如果你是用CreateProcess(NULL, "UtraEdit.exe aaa.txt"...)来打开的话那么返回的那个hProcess就是创建的进程handle,只不过是该进程已经执行完成了,比如UE进程内部可能会判断是否有另一个实例已经运行了,如果是那么将传入的参数通过进程间通讯发给另一个实例然后自身退出了。 但是CreateProcess返回的的确是一个合法进程句柄嘛。 那么你也需要找到另一个进程然后再等待它。
额, 调用了过没用,按说CreateProcess以后,Wait应该阻塞在那的吧,但是,直接就越过去了。那句柄就是失效了呗? 因为比如你用UE打开了个txt文件,此时UE是一个进程,再打开一个txt呢,这时候UE中只是增加了一页,虽然CreateProcess中有那个进程句柄啊,但是那个句柄是无效的啊。
你还能用CreateProcess打开txt? 打开文件关联程序不是ShellExecute干的事吗?如果你是用CreateProcess(NULL, "UtraEdit.exe aaa.txt"...)来打开的话那么返回的那个hProcess就是创建的进程handle,只不过是该进程已经执行完成了,比如UE进程内部可能会判断是否有另一个实例已经运行了,如果是那么将传入的参数通过进程间通讯发给另一个实例然后自身退出了。 但是CreateProcess返回的的确是一个合法进程句柄嘛。 那么你也需要找到另一个进程然后再等待它。额,是这样的,但是对UE来说,一个文件就已经不再是一个进程了,所以,等待UE的进程的话就不大准确了,有没有个其他的办法,能针对于每个文件,判断他关闭的时机