#include <windows.h>
#include <stdio.h>

/* Sample Win32 Program that creates a
   process - it runs Windows notepad.

   This program assumes that notepad.exe
   is in the PATH!

   For information about Win32 system calls, libraries
   and data structures, look at http://msdn.microsoft.com

*/


int main(int argc, char **argv) {

  PROCESS_INFORMATION pi;        /* filled in by CreateProcess */

  STARTUPINFO si;                /* startup info for the new process */

  /* print out our process ID */
  printf("Process %d reporting for duty\n",GetCurrentProcessId());

  /* Get startup info for current process, we will use this
     as the startup info for the new process as well... */

  GetStartupInfo(&si);

  /* Call CreateProcess, telling it to run notepad
     with lots of defaults... (the NULLs mean "use defaults")
  */

  CreateProcess(NULL,          /* lpApplicationName */
		"notepad.exe", /* lpCommandLine */
		NULL,          /* lpsaProcess */
		NULL,          /* lpsaThread */
		FALSE,         /* bInheritHandles */
		DETACHED_PROCESS, /* dwCreationFlags */
		NULL,          /* lpEnvironment */
                NULL,          /* lpCurDir */
                &si,           /* lpStartupInfo */
		&pi            /* lpProcInfo */
		);

  /* print out the new process iD and quit
     (does not wait for new process to exit!)
  */
  printf("New Process ID: %d\n",pi.dwProcessId);
  return(0);
}


