코드 상에서 shellexecute , createprocess 를 이용하면 프로세스를 만들자마자 바로 리턴해버리므로 생성된 프로세스가 아직 제대로 초기화되기 전이라서 내린 지시를 받아들이지 못하는 일이 생길 수 있다. 그런 경우 아래의 함수를 이용하면 해당 프로세스가 초기화를 마치고 사용자의 Input 을 처리할 수 있을 때 까지 기다렸다가 리턴을 해준다.
DWORD WINAPI WaitForInputIdle( __in HANDLE hProcess, __in DWORD dwMilliseconds );
Parameters
- hProcess [in]
A handle to the process. If this process is a console application or does not have a message queue, WaitForInputIdle returns immediately.
- dwMilliseconds [in]
The time-out interval, in milliseconds. If dwMilliseconds is INFINITE, the function does not return until the process is idle.
Return Value
The following table shows the possible return values for this function.
| Return code/value | Description |
|---|---|
|
The wait was satisfied successfully. |
|
The wait was terminated because the time-out interval elapsed. |
|
An error occurred. |
'프로그래밍 > API' 카테고리의 다른 글
| 프로세스가 사용자의 Input을 처리할수 있는 상태 확인 API (0) | 2010/04/20 |
|---|
