Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

ShellExecuteEx 함수 종료시점 잡기

ShellExecuteEx 함수를 사용할 때, 프로그램 실행이 종료 될때 까지 대기해야 할 경우 사용하면 된다. GetExitCodeProcess() 함수의 2번째 인자로 사용되는 ExitCode 변수의 값이 STILL_ACTIVE가 아니라면 종료 되었다는 의미이므로 그 시점을 while 구분을 이용해서 잡는 것이다.. ^^

[code lang=”cpp”] SHELLEXECUTEINFO shExIf;

DWORD dwExitCode;

CString FileName = “jpk.exe”;

shExIf.lpDirectory = “C:my_folder”; shExIf.lpParameters = “”; shExIf.cbSize = sizeof( SHELLEXECUTEINFO ); shExIf.lpVerb = “open”; shExIf.lpFile = FileName; shExIf.nShow = SW_HIDE; shExIf.fMask = SEE_MASK_NOCLOSEPROCESS;

ShellExecuteEx( &shExIf );

dwExitCode = 0;

while(1) { ::GetExitCodeProcess( shExIf.hProcess, &dwExitCode );

if( dwExitCode != STILL_ACTIVE ) { MessageBox(” jpk.exe 종료”); break; } } [/code]

Leave a Reply

Your email address will not be published. Required fields are marked *