From 203495ca2301bb69cea8c21bca30b3015c6bc810 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A7=9C=E6=B5=B7=E5=A4=A9?= <1076168468@qq.com>
Date: Mon, 24 Oct 2022 18:03:00 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E4=BD=BF=E7=94=A8NewTwoProc.c?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 EOSApp.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 62 insertions(+), 7 deletions(-)

diff --git a/EOSApp.c b/EOSApp.c
index d8f2bae..32a69d1 100644
--- a/EOSApp.c
+++ b/EOSApp.c
@@ -1,5 +1,13 @@
+/*
+Ìá¹©¸ÃÊ¾Àý´úÂëÊÇÎªÁË²ûÊÍÒ»¸ö¸ÅÄî£¬»òÕß½øÐÐÒ»¸ö²âÊÔ£¬²¢²»´ú±í×Å
+×î°²È«µÄ±àÂëÊµ¼ù£¬Òò´Ë²»Ó¦ÔÚÓ¦ÓÃ³ÌÐò»òÍøÕ¾ÖÐÊ¹ÓÃ¸ÃÊ¾Àý´úÂë¡£¶Ô
+ÓÚ³¬³ö±¾Ê¾Àý´úÂëµÄÔ¤ÆÚÓÃÍ¾ÒÔÍâµÄÊ¹ÓÃËùÔì³ÉµÄÅ¼È»»ò¼Ì·¢ÐÔËðÊ§£¬
+±±¾©Ó¢ÕæÊ±´ú¿Æ¼¼ÓÐÏÞ¹«Ë¾²»³Ðµ£ÈÎºÎÔðÈÎ¡£
+*/
+
 #include "EOSApp.h"
 
+
 //
 // main º¯Êý²ÎÊýµÄÒâÒå£º
 // argc - argv Êý×éµÄ³¤¶È£¬´óÐ¡ÖÁÉÙÎª 1£¬argc - 1 ÎªÃüÁîÐÐ²ÎÊýµÄÊýÁ¿¡£
@@ -13,14 +21,61 @@
 int main(int argc, char* argv[])
 {
 	//
-	// Èç¹ûÐèÒªÔÚµ÷ÊÔÓ¦ÓÃ³ÌÐòÊ±ÄÜ¹»µ÷ÊÔ½øÈëÄÚºË²¢ÏÔÊ¾¶ÔÓ¦µÄÔ´Âë£¬
-	// ±ØÐëÊ¹ÓÃ EOS ÄÚºËÏîÄ¿±àÒëÉú³ÉÍêÈ«°æ±¾µÄ SDK ÎÄ¼þ¼Ð£¬È»
-	// ºóÊ¹ÓÃ¸Õ¸ÕÉú³ÉµÄ SDK ÎÄ¼þ¼Ð¸²¸Ç´ËÓ¦ÓÃ³ÌÐòÏîÄ¿ÖÐµÄ SDK ÎÄ¼þ
-	// ¼Ð£¬²¢ÇÒ EOS ÄÚºËÏîÄ¿ÔÚ´ÅÅÌÉÏµÄÎ»ÖÃ²»ÄÜ¸Ä±ä¡£
+	// Æô¶¯µ÷ÊÔ EOS Ó¦ÓÃ³ÌÐòÇ°ÒªÌØ±ð×¢ÒâÏÂÃæµÄÎÊÌâ£º
+	//
+	// 1¡¢Èç¹ûÒªÔÚµ÷ÊÔÓ¦ÓÃ³ÌÐòÊ±ÄÜ¹»µ÷ÊÔ½øÈëÄÚºË²¢ÏÔÊ¾¶ÔÓ¦µÄÔ´Âë£¬
+	//    ±ØÐëÊ¹ÓÃ EOS ºËÐÄÏîÄ¿±àÒëÉú³ÉÍêÈ«°æ±¾µÄ SDK ÎÄ¼þ¼Ð£¬È»
+	//    ºóÊ¹ÓÃ´ËÎÄ¼þ¼Ð¸²¸ÇÓ¦ÓÃ³ÌÐòÏîÄ¿ÖÐµÄ SDK ÎÄ¼þ¼Ð£¬²¢ÇÒ EOS
+	//    ºËÐÄÏîÄ¿ÔÚ´ÅÅÌÉÏµÄÎ»ÖÃ²»ÄÜ¸Ä±ä¡£
+	//
+	
+	STARTUPINFO StartupInfo;
+	PROCESS_INFORMATION ProcInfoOne, ProcInfoTwo;
+	ULONG ulExitCode;	// ×Ó½ø³ÌÍË³öÂë
+	INT nResult = 0;	// main º¯Êý·µ»ØÖµ¡£0 ±íÊ¾³É¹¦£¬·Ç 0 ±íÊ¾Ê§°Ü¡£
+
+	printf("Create two processes and wait for the processes exit...\n\n");
+
+	//
+	// Ê¹×Ó½ø³ÌºÍ¸¸½ø³ÌÊ¹ÓÃÏàÍ¬µÄ±ê×¼¾ä±ú¡£
 	//
+	StartupInfo.StdInput = GetStdHandle(STD_INPUT_HANDLE);
+	StartupInfo.StdOutput = GetStdHandle(STD_OUTPUT_HANDLE);
+	StartupInfo.StdError = GetStdHandle(STD_ERROR_HANDLE);
+
+	//
+	// ÎªÒ»¸öÓ¦ÓÃ³ÌÐòÍ¬Ê±´´½¨Á½¸ö×Ó½ø³Ì¡£
+	//
+	if (CreateProcess("A:\\Hello.exe", NULL, 0, &StartupInfo, &ProcInfoOne)
+		&& CreateProcess("A:\\Hello.exe", NULL, 0, &StartupInfo, &ProcInfoTwo)) {
+
+		//
+		// ´´½¨×Ó½ø³Ì³É¹¦£¬µÈ´ý×Ó½ø³ÌÔËÐÐ½áÊø¡£
+		//
+		WaitForSingleObject(ProcInfoOne.ProcessHandle, INFINITE);
+		WaitForSingleObject(ProcInfoTwo.ProcessHandle, INFINITE);
+
+		//
+		// µÃµ½²¢Êä³ö×Ó½ø³ÌµÄÍË³öÂë¡£
+		//
+		GetExitCodeProcess(ProcInfoOne.ProcessHandle, &ulExitCode);
+		printf("\nThe process one exit with %d.\n", ulExitCode);
+		GetExitCodeProcess(ProcInfoTwo.ProcessHandle, &ulExitCode);
+		printf("\nThe process two exit with %d.\n", ulExitCode);
+
+		//
+		// ¹Ø±Õ²»ÔÙÊ¹ÓÃµÄ¾ä±ú¡£
+		//
+		CloseHandle(ProcInfoOne.ProcessHandle);
+		CloseHandle(ProcInfoOne.ThreadHandle);
+		CloseHandle(ProcInfoTwo.ProcessHandle);
+		CloseHandle(ProcInfoTwo.ThreadHandle);
+
+	} else {
 
-	/* TODO: ÔÚ´Ë´¦Ìí¼Ó×Ô¼ºµÄ´úÂë */
-	printf("Hello world!\n");
+		printf("CreateProcess Failed, Error code: 0x%X.\n", GetLastError());
+		nResult = 1;
+	}
 
-	return 0;
+	return nResult;
 }
-- 
2.34.1.windows.1


From b7fd4157fc78c124305a6f6df6b2e05eb794291b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=A7=9C=E6=B5=B7=E5=A4=A9?= <1076168468@qq.com>
Date: Mon, 24 Oct 2022 18:18:07 +0800
Subject: [PATCH 2/2] =?UTF-8?q?=E8=BF=90=E8=A1=8C10=E4=B8=AA=E8=BF=9B?=
 =?UTF-8?q?=E7=A8=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 EOSApp.c | 67 +++++++++++++++++++++++---------------------------------
 1 file changed, 28 insertions(+), 39 deletions(-)

diff --git a/EOSApp.c b/EOSApp.c
index 32a69d1..fbcd75d 100644
--- a/EOSApp.c
+++ b/EOSApp.c
@@ -20,21 +20,12 @@
 //
 int main(int argc, char* argv[])
 {
-	//
-	// Æô¶¯µ÷ÊÔ EOS Ó¦ÓÃ³ÌÐòÇ°ÒªÌØ±ð×¢ÒâÏÂÃæµÄÎÊÌâ£º
-	//
-	// 1¡¢Èç¹ûÒªÔÚµ÷ÊÔÓ¦ÓÃ³ÌÐòÊ±ÄÜ¹»µ÷ÊÔ½øÈëÄÚºË²¢ÏÔÊ¾¶ÔÓ¦µÄÔ´Âë£¬
-	//    ±ØÐëÊ¹ÓÃ EOS ºËÐÄÏîÄ¿±àÒëÉú³ÉÍêÈ«°æ±¾µÄ SDK ÎÄ¼þ¼Ð£¬È»
-	//    ºóÊ¹ÓÃ´ËÎÄ¼þ¼Ð¸²¸ÇÓ¦ÓÃ³ÌÐòÏîÄ¿ÖÐµÄ SDK ÎÄ¼þ¼Ð£¬²¢ÇÒ EOS
-	//    ºËÐÄÏîÄ¿ÔÚ´ÅÅÌÉÏµÄÎ»ÖÃ²»ÄÜ¸Ä±ä¡£
-	//
 	
 	STARTUPINFO StartupInfo;
-	PROCESS_INFORMATION ProcInfoOne, ProcInfoTwo;
+	PROCESS_INFORMATION ProcInfo[10];
 	ULONG ulExitCode;	// ×Ó½ø³ÌÍË³öÂë
-	INT nResult = 0;	// main º¯Êý·µ»ØÖµ¡£0 ±íÊ¾³É¹¦£¬·Ç 0 ±íÊ¾Ê§°Ü¡£
 
-	printf("Create two processes and wait for the processes exit...\n\n");
+	printf("Create ten processes and wait for the processes exit...\n\n");
 
 	//
 	// Ê¹×Ó½ø³ÌºÍ¸¸½ø³ÌÊ¹ÓÃÏàÍ¬µÄ±ê×¼¾ä±ú¡£
@@ -44,38 +35,36 @@ int main(int argc, char* argv[])
 	StartupInfo.StdError = GetStdHandle(STD_ERROR_HANDLE);
 
 	//
-	// ÎªÒ»¸öÓ¦ÓÃ³ÌÐòÍ¬Ê±´´½¨Á½¸ö×Ó½ø³Ì¡£
+	// ÎªÒ»¸öÓ¦ÓÃ³ÌÐòÍ¬Ê±´´½¨10¸ö×Ó½ø³Ì¡£
 	//
-	if (CreateProcess("A:\\Hello.exe", NULL, 0, &StartupInfo, &ProcInfoOne)
-		&& CreateProcess("A:\\Hello.exe", NULL, 0, &StartupInfo, &ProcInfoTwo)) {
-
-		//
-		// ´´½¨×Ó½ø³Ì³É¹¦£¬µÈ´ý×Ó½ø³ÌÔËÐÐ½áÊø¡£
-		//
-		WaitForSingleObject(ProcInfoOne.ProcessHandle, INFINITE);
-		WaitForSingleObject(ProcInfoTwo.ProcessHandle, INFINITE);
-
-		//
-		// µÃµ½²¢Êä³ö×Ó½ø³ÌµÄÍË³öÂë¡£
-		//
-		GetExitCodeProcess(ProcInfoOne.ProcessHandle, &ulExitCode);
-		printf("\nThe process one exit with %d.\n", ulExitCode);
-		GetExitCodeProcess(ProcInfoTwo.ProcessHandle, &ulExitCode);
-		printf("\nThe process two exit with %d.\n", ulExitCode);
-
+	int i;
+	for(i=0;i<10;++i){
+		if(!CreateProcess("A:\\Hello.exe", NULL, 0, &StartupInfo, &ProcInfo[i])){
+			printf("CreateProcess Failed, Error code: 0x%X.\n", GetLastError());
+			return 1;
+		}
+	}
+	
+	//
+	// ´´½¨×Ó½ø³Ì³É¹¦£¬µÈ´ý×Ó½ø³ÌÔËÐÐ½áÊø¡£
+	//
+	for(i=0;i<10;++i){
+		WaitForSingleObject(ProcInfo[i].ProcessHandle, INFINITE);
+	}
+	
+	//
+	// µÃµ½²¢Êä³ö×Ó½ø³ÌµÄÍË³öÂë¡£
+	//
+	for(i=0;i<10;++i){
+		GetExitCodeProcess(ProcInfo[i].ProcessHandle, &ulExitCode);
+		printf("\nThe process %d exit with %d.\n", i, ulExitCode);
+		
 		//
 		// ¹Ø±Õ²»ÔÙÊ¹ÓÃµÄ¾ä±ú¡£
 		//
-		CloseHandle(ProcInfoOne.ProcessHandle);
-		CloseHandle(ProcInfoOne.ThreadHandle);
-		CloseHandle(ProcInfoTwo.ProcessHandle);
-		CloseHandle(ProcInfoTwo.ThreadHandle);
-
-	} else {
-
-		printf("CreateProcess Failed, Error code: 0x%X.\n", GetLastError());
-		nResult = 1;
+		CloseHandle(ProcInfo[i].ProcessHandle);
+		CloseHandle(ProcInfo[i].ThreadHandle);
 	}
 
-	return nResult;
+	return 0;
 }
-- 
2.34.1.windows.1

