Click here to Skip to main content
15,918,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
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 
Thanks for the help Andrzej
I have configured the code as shown below: Including a couple of functions. The program builds with 0 errors and 0 warnings, but for some reason when I enter a choice like (1) for "Freecell", my program quits, the program that I have opened remains open, so I do not have the chance to quit the Freecell program. Not sure why it is not giving me another choice:

#include <iostream.h><br />
#include <windows.h><br />
#include <string.h><br />
#include <stdio.h><br />
<br />
void DisplayMenu();<br />
void process(int option);<br />
<br />
<br />
void main()<br />
{<br />
	DisplayMenu();<br />
	return;<br />
}<br />
<br />
void DisplayMenu()<br />
{<br />
	int option;<br />
<br />
	cout << "\n\n\n";<br />
	cout << "\n\t*********************************";<br />
	cout << "\n\t*				*";<br />
	cout << "\n\t*	MENU			*";<br />
	cout << "\n\t*			  	*";<br />
	cout << "\n\t*	1. FreeCell		*";<br />
	cout << "\n\t*	2. MineSweeper		*";<br />
	cout << "\n\t*	3. Paint		*";<br />
	cout << "\n\t*	4. Quit			*";<br />
	cout << "\n\t*			  	*";<br />
	cout << "\n\t*********************************";<br />
<br />
	cout << "\n\nPlease type your choice "<br />
		 << "and press the return key : ";<br />
<br />
	cin >> option;<br />
	process(option);<br />
<br />
	return;<br />
}<br />
<br />
void process(int option)<br />
{<br />
	<br />
	STARTUPINFO si[3];<br />
	PROCESS_INFORMATION pi[3];	<br />
	int i=0;<br />
	<br />
	ZeroMemory( &si[0], sizeof(si[0]) );<br />
	si[0].cb = sizeof(si[0]); <br />
	ZeroMemory( &pi[0], sizeof(pi[0]) ); <br />
<br />
	ZeroMemory( &si[1], sizeof(si[1]) );<br />
	si[1].cb = sizeof(si[1]); <br />
	ZeroMemory( &pi[1], sizeof(pi[1]) ); <br />
<br />
	ZeroMemory( &si[2], sizeof(si[2]) );<br />
	si[2].cb = sizeof(si[2]); <br />
	ZeroMemory( &pi[2], sizeof(pi[2]) ); <br />
<br />
	switch (option)<br />
	{<br />
	case 1 : if(pi[0].hProcess==NULL)CreateProcess( NULL, 				 <br />
		"FreeCell.exe", 						 <br />
		    NULL,             					 <br />
			NULL,             					<br />
			FALSE,            					<br />
			NULL,							 <br />
			NULL,            					 <br />
			NULL,             					 <br />
			&si[0],              					<br />
			&pi[0]);             					<br />
		  <br />
				{<br />
					ExitProcess(1);<br />
				}		<br />
	<br />
	<br />
		system("cls");<br />
		DisplayMenu();<br />
	<br />
		break; <br />
<br />
	case 2 : if(pi[1].hProcess==NULL)CreateProcess( NULL, 				<br />
		"winmine.exe", 	<br />
		    NULL,             					<br />
			NULL,             					<br />
			FALSE,            					<br />
			NULL,								<br />
			NULL,            					<br />
			NULL,             					<br />
			&si[1],              					<br />
			&pi[1]);             					<br />
		  <br />
				{<br />
					ExitProcess(1);<br />
				}		<br />
		<br />
	<br />
		system("cls");<br />
		DisplayMenu();<br />
<br />
		break;<br />
<br />
	case 3 : if(pi[2].hProcess==NULL)CreateProcess( NULL, 			<br />
		"MsPaint.exe", 	// Command line. <br />
		    NULL,             					<br />
			NULL,             					<br />
			FALSE,            					 <br />
			NULL,								 <br />
			NULL,            					 <br />
			NULL,             					<br />
			&si[2],              					<br />
			&pi[2]);             					<br />
		  <br />
				{<br />
					ExitProcess(1);<br />
				}		<br />
	<br />
		system("cls");<br />
		DisplayMenu();<br />
	<br />
		break;<br />
<br />
	<br />
<br />
	case 4 : if(pi[0].hProcess)::PostThreadMessage(pi[0].dwThreadId,WM_QUIT,0,0);<br />
		if(pi[1].hProcess)::PostThreadMessage(pi[1].dwThreadId,WM_QUIT,0,0);<br />
		if(pi[2].hProcess)::PostThreadMessage(pi[2].dwThreadId,WM_QUIT,0,0);<br />
		CloseHandle( pi[0].hProcess );<br />
		CloseHandle( pi[0].hThread );<br />
		CloseHandle( pi[1].hProcess );<br />
		CloseHandle( pi[1].hThread );<br />
		CloseHandle( pi[2].hProcess );<br />
		CloseHandle( pi[2].hThread );<br />
	//	CloseHandle( pi[3].hProcess );<br />
	//	CloseHandle( pi[3].hThread );<br />
		exit(100);<br />
	<br />
		break;<br />
	<br />
	default : printf("\a\aOption Not Available\n");<br />
	system("cls");<br />
	DisplayMenu();<br />
	}<br />
<br />
return;<br />
}

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 
QuestionHow To Hold a Key Pin
Dody_DK14-Oct-04 11:48
Dody_DK14-Oct-04 11:48 
AnswerRe: How To Hold a Key Pin
ThatsAlok14-Oct-04 18:42
ThatsAlok14-Oct-04 18:42 
AnswerRe: How To Hold a Key Pin
toxcct14-Oct-04 20:01
toxcct14-Oct-04 20:01 
GeneralRe: How To Hold a Key Pin
Dody_DK17-Oct-04 9:56
Dody_DK17-Oct-04 9:56 
Generalmessage reflection Pin
prateekkathuria14-Oct-04 11:47
prateekkathuria14-Oct-04 11:47 

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.