Click here to Skip to main content
15,923,087 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to pass data to and from two forms? Pin
Sujan Christo14-Oct-04 19:22
Sujan Christo14-Oct-04 19:22 
AnswerRe: How to pass data to and from two forms? Pin
Michael P Butler15-Oct-04 0:33
Michael P Butler15-Oct-04 0:33 
GeneralOwner-drawn CListBox-derived background color question Pin
Indrawati14-Oct-04 14:44
Indrawati14-Oct-04 14:44 
GeneralRe: Owner-drawn CListBox-derived background color question Pin
Mad__14-Oct-04 23:06
Mad__14-Oct-04 23:06 
GeneralRe: Owner-drawn CListBox-derived background color question Pin
Antony M Kancidrowski14-Oct-04 23:08
Antony M Kancidrowski14-Oct-04 23:08 
GeneralMaking an application non-resizable Pin
help_wanted14-Oct-04 14:42
help_wanted14-Oct-04 14:42 
GeneralRe: Making an application non-resizable Pin
Sujan Christo14-Oct-04 19:16
Sujan Christo14-Oct-04 19:16 
QuestionHow to close other processes? Pin
Moochie514-Oct-04 14:04
Moochie514-Oct-04 14:04 
Hello, I'm creating a program that displays a menu to the user and gives the user the option to open the following programs:
1. Freecell
2. Minesweeper
3. Paint
4. Quit
It does open the programs correctly but when the user enters 4 for quit, I want my program to close all of the programs the user opened. I am not sure how to do that though. I have created a function called ExitProcess and have a call to it when the user enters 4 as their choice. There is no code in that function.

Here is most of the code:

#include <iostream.h><br />
#include <windows.h><br />
#include <string.h><br />
#include <stdio.h><br />
<br />
void DisplayMenu();<br />
void CreateProcess(int option);<br />
void ExitProcess(void);<br />
// Main<br />
void main()<br />
{<br />
	DisplayMenu();<br />
<br />
	return;<br />
}<br />
<br />
void DisplayMenu()<br />
{<br />
	int option;<br />
<br />
        //MENU IS DISPLAYED HERE<br />
<br />
	cout << "\n\nPlease type your choice "<br />
		 << "and press the return key : ";<br />
<br />
	cin >> option;<br />
	CreateProcess(option);<br />
<br />
	return;<br />
}<br />
<br />
void CreateProcess(int option)<br />
{<br />
	STARTUPINFO si;<br />
	PROCESS_INFORMATION pi;	<br />
<br />
	ZeroMemory( &si, sizeof(si) );<br />
	si.cb = sizeof(si);	<br />
	ZeroMemory( &pi, sizeof(pi) );	<br />
<br />
	switch (option)<br />
	{<br />
	case 1 : if( !CreateProcess( NULL, 				<br />
		"C://FreeCell.exe",NULL,NULL,FALSE,NULL,NULL,NULL,&si,&pi)) <br />
				{<br />
					ExitProcess(1);<br />
				}		<br />
		system("cls");<br />
		DisplayMenu();<br />
	<br />
		break; <br />
<br />
	case 2 : if( !CreateProcess( NULL, 				<br />
		"winmine.exe",NULL,NULL,FALSE,NULL,NULL,NULL,&si,&pi))             					 <br />
				{<br />
					ExitProcess(1);<br />
				}		<br />
		system("cls");<br />
		DisplayMenu();<br />
<br />
		break;<br />
<br />
	case 3 : if( !CreateProcess( NULL, 				<br />
		"MsPaint.exe",NULL,NULL,FALSE, NULL,NULL,NULL,&si,&pi ))           					<br />
			   	{<br />
					ExitProcess(1);<br />
				}		<br />
	<br />
		system("cls");<br />
		DisplayMenu();<br />
	<br />
		break;<br />
<br />
	<br />
<br />
	case 4 : WaitForSingleObject( pi.hProcess, INFINITE );<br />
		ExitProcess();<br />
		CloseHandle( pi.hProcess );<br />
		CloseHandle( pi.hThread );<br />
	<br />
		exit(100);<br />
		<br />
		break;<br />
	<br />
<br />
	default : cout << "\a\aOption Not Available\n";<br />
	system("cls");<br />
	DisplayMenu();<br />
	}<br />
<br />
return;<br />
}<br />
void ExitProcess(void)<br />
{<br />
<br />
}

AnswerRe: How to close other processes? Pin
Andrzej Markowski14-Oct-04 16:05
Andrzej Markowski14-Oct-04 16:05 
GeneralRe: How to close other processes? Pin
vikramlinux14-Oct-04 19:22
vikramlinux14-Oct-04 19:22 
GeneralRe: How to close other processes? Pin
Moochie515-Oct-04 6:27
Moochie515-Oct-04 6:27 
GeneralRe: How to close other processes? Pin
Andrzej Markowski15-Oct-04 7:04
Andrzej Markowski15-Oct-04 7:04 
GeneralRe: How to close other processes? Pin
Moochie515-Oct-04 8:14
Moochie515-Oct-04 8:14 
GeneralRe: How to close other processes? Pin
Andrzej Markowski15-Oct-04 9:32
Andrzej Markowski15-Oct-04 9:32 
GeneralRe: How to close other processes? Pin
Moochie515-Oct-04 10:53
Moochie515-Oct-04 10:53 
GeneralRe: How to close other processes? Pin
Moochie516-Oct-04 9:46
Moochie516-Oct-04 9:46 
GeneralRe: How to close other processes? Pin
Moochie516-Oct-04 10:01
Moochie516-Oct-04 10:01 
GeneralRe: How to close other processes? Pin
Andrzej Markowski17-Oct-04 11:54
Andrzej Markowski17-Oct-04 11:54 
AnswerRe: How to close other processes? Pin
Andrzej Markowski21-Oct-04 8:38
Andrzej Markowski21-Oct-04 8:38 
AnswerRe: How to close other processes? Pin
Andrzej Markowski23-Oct-04 19:16
Andrzej Markowski23-Oct-04 19:16 
QuestionProblem trying to create an alpha surface? Pin
Dani10000114-Oct-04 12:12
Dani10000114-Oct-04 12:12 
Generaldouble-clicking application causes error Pin
dotbomb14-Oct-04 12:02
dotbomb14-Oct-04 12:02 
GeneralRe: double-clicking application causes error Pin
Joaquín M López Muñoz14-Oct-04 12:15
Joaquín M López Muñoz14-Oct-04 12:15 
GeneralRe: double-clicking application causes error Pin
dotbomb14-Oct-04 12:23
dotbomb14-Oct-04 12:23 
GeneralRe: double-clicking application causes error Pin
Joaquín M López Muñoz14-Oct-04 12:44
Joaquín M López Muñoz14-Oct-04 12:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.