2010-02-12 31 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