[HCPC] Win32.Process.Create&Wait

// Win32でのプロセス作成と待機 Ver.2008.4.14
// Copyright (C) 2008 T.Hirase, All rights reserved.
//-----------------------------------------------------
#include <windows.h>

int main()
{
	TCHAR *cmdline = _T("C:\\windows\\notepad.exe");
	STARTUPINFO si = {sizeof(si)};
	PROCESS_INFORMATION pi;
	ZeroMemory(&pi, sizeof(pi));
	if (CreateProcess(cmdline, NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
	{
		WaitForSingleObject(pi.hProcess, INFINITE);

		DWORD returnCode;
		GetExitCodeProcess(pi.hProcess, &returnCode);
		CloseHandle(pi.hProcess);
		CloseHandle(pi.hThread);
	}
	return 0;
}

更新履歴

2008.04.14
(初)