|
void
LoadNotepad( void ) {
int ret;
PROCESS_INFORMATION pi;
STARTUPINFO si;
ZeroMemory( &pi , sizeof(PROCESS_INFORMATION));
ZeroMemory( &si , sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOWNORMAL;
ret = CreateProcess( NULL, "notepad.exe", NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
WaitForInputIdle(pi.hProcess,INFINITE);
DWORD procStatus;
MSG msg;
while (1) {
while (PeekMessage(&msg, (HWND)NULL, 0, 0, PM_REMOVE) ) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
GetExitCodeProcess( pi.hProcess, &procStatus ) ;
if ( procStatus != STILL_ACTIVE ) {
break;
}
}
CloseHandle(pi.hProcess);
MessageBox( NULL, "Notepad.exe が終了しました", "End Process!", MB_OK );
}
| |