Click here to Skip to main content
15,917,177 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: How to close other processes? Pin
Andrzej Markowski15-Oct-04 9:32
Andrzej Markowski15-Oct-04 9:32 
You should declare the arrays (si and pi) as global variables. Also you can't call the DisplayMenu from within the process function (recursion).
Here's an example how to fix these problems:
STARTUPINFO si[3];
PROCESS_INFORMATION pi[3]; 

int DisplayMenu();
void process(int option);

void main()
{
ZeroMemory( &si[0], sizeof(si[0]) );
si[0].cb = sizeof(si[0]); 
ZeroMemory( &pi[0], sizeof(pi[0]) ); 

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

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

while(DisplayMenu()!=4)
return;
}

int DisplayMenu()
{
int option;
system("cls");
cout << "\n\n\n";
cout << "\n\t*********************************";
cout << "\n\t* *";
cout << "\n\t* MENU *";
cout << "\n\t* *";
cout << "\n\t* 1. FreeCell *";
cout << "\n\t* 2. MineSweeper *";
cout << "\n\t* 3. Paint *";
cout << "\n\t* 4. Quit *";
cout << "\n\t* *";
cout << "\n\t*********************************";

cout << "\n\nPlease type your choice "
<< "and press the return key : ";

cin >> option;
process(option);
return option;
}

void process(int option)
{
switch (option)
{
case 1 : if(pi[0].hProcess==NULL)CreateProcess( NULL, 
"FreeCell.exe", 
NULL, 
NULL, 
FALSE, 
NULL, 
NULL, 
NULL, 
&si[0], 
&pi[0]); 

break; 

case 2 : if(pi[1].hProcess==NULL)CreateProcess( NULL, 
"winmine.exe", 
NULL, 
NULL, 
FALSE, 
NULL, 
NULL, 
NULL, 
&si[1], 
&pi[1]); 

break;

case 3 : if(pi[2].hProcess==NULL)CreateProcess( NULL, 
"MsPaint.exe", // Command line. 
NULL, 
NULL, 
FALSE, 
NULL, 
NULL, 
NULL, 
&si[2], 
&pi[2]); 

break;

case 4 : if(pi[0].hProcess)::PostThreadMessage(pi[0].dwThreadId,WM_QUIT,0,0);
if(pi[1].hProcess)::PostThreadMessage(pi[1].dwThreadId,WM_QUIT,0,0);
if(pi[2].hProcess)::PostThreadMessage(pi[2].dwThreadId,WM_QUIT,0,0);
CloseHandle( pi[0].hProcess );
CloseHandle( pi[0].hThread );
CloseHandle( pi[1].hProcess );
CloseHandle( pi[1].hThread );
CloseHandle( pi[2].hProcess );
CloseHandle( pi[2].hThread );
// CloseHandle( pi[3].hProcess );
// CloseHandle( pi[3].hThread );

break;

default : printf("\a\aOption Not Available\n");
break;
}

return;
}

Regards,
Andrzej Markowski

My Latest ArticlesCCustomBitmapButton: An owner-draw button and a frame for the caption bar, in one class.
CCustomTabCtrl: A clone of the Excel tab sheet control.

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 
GeneralRe: message reflection Pin
prateekkathuria14-Oct-04 12:33
prateekkathuria14-Oct-04 12:33 

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.