2010-02-12 123 views

回答

1

WinExec仅用于兼容16位Windows。执行程序,并等待最简单的方法是使用系统():

#include <stdlib.h> 

int main() { 
    system("notepad"); 
    // only gets to here when the notepad instance is closed 
} 
+0

WinExec is needed – SomeUser 2010-02-12 22:43:55

+0

@AndrewSmith为什么会这样? – 2010-02-12 22:45:13

+0

WinExec适用于GUI应用程序,而system()启动控制台。不是等同的替代品。无论如何,对于GUI应用程序来说,system()不会等待完成。 – 2010-02-12 22:55:05

2

严格来说,你不能。 WinExec将尽快返回(备注部分在WinExec MSDN page),而不像CreateProcess,它甚至不会返回一个句柄,你可以调用WaitForSingleObject