#include <windows.h>
#include <stdio.h>

#pragma argsused
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
{
    STARTUPINFO si,si1;
    PROCESS_INFORMATION pi,pi1;
    HANDLE prochand[5];

	ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

    ZeroMemory( &si1, sizeof(si1) );
    si1.cb = sizeof(si1);
    ZeroMemory( &pi1, sizeof(pi1) );


    if( !CreateProcess( NULL,   // No module name (use command line)
        "msgbox.exe",        // Command line
        NULL,           // Process handle not inheritable
        NULL,           // Thread handle not inheritable
        FALSE,          // Set handle inheritance to FALSE
        0,              // No creation flags
        NULL,           // Use parent's environment block
        NULL,           // Use parent's starting directory 
        &si,            // Pointer to STARTUPINFO structure
        &pi )           // Pointer to PROCESS_INFORMATION structure
    ) 
    {
        printf( "CreateProcess failed (%d)\n", GetLastError() );
        return 0;
    }
    prochand[0] = pi.hProcess;

    // Wait until child process exits.
    WaitForSingleObject( pi.hProcess , INFINITE );

    // Close process and thread handles. 
    CloseHandle( pi.hProcess );
    CloseHandle( pi.hThread );

	MessageBox(0,"another createprocess","Practice",0);

	if( !CreateProcess( NULL,   // No module name (use command line)
        "msgbox.exe",        // Command line
        NULL,           // Process handle not inheritable
        NULL,           // Thread handle not inheritable
        FALSE,          // Set handle inheritance to FALSE
        0,              // No creation flags
        NULL,           // Use parent's environment block
        NULL,           // Use parent's starting directory 
        &si1,            // Pointer to STARTUPINFO structure
        &pi1 )           // Pointer to PROCESS_INFORMATION structure
    ) 
    {
        printf( "CreateProcess failed (%d)\n", GetLastError() );
        return 0;
    }
    prochand[1] = pi1.hProcess;

	WaitForSingleObject(pi1.hProcess,INFINITE);
	CloseHandle( pi1.hProcess );
    CloseHandle( pi1.hThread );

    return 1;
}