I have this problem where I have to create a process and then when I am all done i must delete all processes that are created. I have tried to set up a linked list to do this but when i go to implement it it doesnt work>> I have all of my code up here for your use.

#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
#include <process.h>


struct Node
{
	info p;
	Node *next;
};
Node* head = NULL;

void addprocess(void)
{
	Node* t;
	t = new(node);
	t->p = p1;
	t->next = head;
	head = t;
}
void closeprocess(void)
{
	Node* t;
	t = head;
	while(t != NULL)
	{
		TerminateProcess(t->p.hprocess, 0);
		t = t->next;
	}
}
		


void menu (void)
{ int choice;
	do
	{
		
		cout << "                      ---1.  Calculator ---" << endl;
		cout << "                      ---2.  Notepad    ---" << endl;
		cout << "                      ---3.  Paint      ---"<< endl;
		cout << "                      ---4.  Terminate  ---" << endl;
		cin >> choice;
	
	
					char lpApplicationName[100];
					STARTUPINFO StartInfo;
					PROCESS_INFORMATION ProcessInfo;					
					ZeroMemory(&StartInfo, sizeof(StartInfo));
					StartInfo.cb = sizeof(StartInfo);
						if(choice == 1)
					{
						strcpy(lpApplicationName, "C:\\Windows\\system32\\calc.exe");
						addprocess();
					}
						if(choice == 2)
						{
							strcpy(lpApplicationName, "C:\\Windows\\system32\\Notepad.exe");
							addprocess();
						}
						if(choice == 3)
						{
							strcpy(lpApplicationName, "C:\\Windows\\system32\\mspaint.exe");
							addprocess();
						}
						if (choice == 4)
						{
							closeprocess();
						}
		CreateProcess (lpApplicationName, NULL, NULL, NULL, FALSE, HIGH_PRIORITY_CLASS|CREATE_NEW_CONSOLE, NULL, NULL, &StartInfo, &ProcessInfo);	

	}while(choice != 4);			
}
	



void main(void)

{
	

	menu();
	
}
t->p = [B]p1[/B];

What is this p1 inside the addprocess function?

struct Node
{
	[B]info[/B] p;
	Node *next;
};

What is the type called info inside the Node structure?

Does this code compile?

Anyway you should add the ProcessHandle returned in ProcessInfo to the linked list. Otherwise you have no way of accessing the created process inside the closeprocess function.

sorry about the info thing i was supposed to put PROCESS_INFORMATION i kinda abb it i tried to fix it up a bit here but i get errors saying that the fucntions do not take zero parameters

#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
#include <process.h>


struct Node
{
	PROCESS_INFORMATION p;
	Node *next;
};
Node* head = NULL;

void addprocess(PROCESS_INFORMATION p1, Node *cur)
{
	Node* t;
	t = new(Node);
	t->p = p1;
	t->next = head;
	head = t;
};

void closeprocess(Node *head)
{
	Node* t;
	t = head;
	while(t != NULL)
	{
		TerminateProcess(t->p.hProcess, 0);
		t = t->next;
	};
};
		


void menu (void)
{ int choice;
	do
	{
		
		cout << "                      ---1.  Calculator ---" << endl;
		cout << "                      ---2.  Notepad    ---" << endl;
		cout << "                      ---3.  Paint      ---"<< endl;
		cout << "                      ---4.  Terminate  ---" << endl;
		cin >> choice;
	
	
					char lpApplicationName[100];
					STARTUPINFO StartInfo;
					PROCESS_INFORMATION ProcessInfo;					
					ZeroMemory(&StartInfo, sizeof(StartInfo));
					StartInfo.cb = sizeof(StartInfo);
						if(choice == 1)
					{
						strcpy(lpApplicationName, "C:\\Windows\\system32\\calc.exe");
						addprocess();
					}
						if(choice == 2)
						{
							strcpy(lpApplicationName, "C:\\Windows\\system32\\Notepad.exe");
							addprocess();
						}
						if(choice == 3)
						{
							strcpy(lpApplicationName, "C:\\Windows\\system32\\mspaint.exe");
							addprocess();
						}
						if (choice == 4)
						{
							closeprocess();
						}
		CreateProcess (lpApplicationName, NULL, NULL, NULL, FALSE, HIGH_PRIORITY_CLASS|CREATE_NEW_CONSOLE, NULL, NULL, &StartInfo, &ProcessInfo);	

	}while(choice != 4);			
}
	



void main(void)

{
	

	menu();
	
}

i get errors saying that the fucntions do not take zero parameters

#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
#include <process.h>


struct Node
{
	PROCESS_INFORMATION p;
	Node *next;
};
Node* head = NULL;

void addprocess(PROCESS_INFORMATION p1, Node *cur)
{
	Node* t;
	t = new(Node);
	t->p = p1;
	t->next = head;
	head = t;
};

void closeprocess(Node *head)
{
	Node* t;
	t = head;
	while(t != NULL)
	{
		TerminateProcess(t->p.hProcess, 0);
		t = t->next;
	};
};
		


void menu (void)
{ int choice;
  
	do
	{
		
		cout << "                      ---1.  Calculator ---" << endl;
		cout << "                      ---2.  Notepad    ---" << endl;
		cout << "                      ---3.  Paint      ---"<< endl;
		cout << "                      ---4.  Terminate  ---" << endl;
		cin >> choice;
	
	
					char lpApplicationName[100];
					STARTUPINFO StartInfo;
					PROCESS_INFORMATION ProcessInfo;					
					ZeroMemory(&StartInfo, sizeof(StartInfo));
					StartInfo.cb = sizeof(StartInfo);
						if(choice == 1)
					{
						strcpy(lpApplicationName, "C:\\Windows\\system32\\calc.exe");
						addprocess();
					}
						if(choice == 2)
						{
							strcpy(lpApplicationName, "C:\\Windows\\system32\\Notepad.exe");
							addprocess();
						}
						if(choice == 3)
						{
							strcpy(lpApplicationName, "C:\\Windows\\system32\\mspaint.exe");
							addprocess();
						}
						if (choice == 4)
						{
							closeprocess();
						}
		CreateProcess (lpApplicationName, NULL, NULL, NULL, FALSE, HIGH_PRIORITY_CLASS|CREATE_NEW_CONSOLE, NULL, NULL, &StartInfo, &ProcessInfo);	

	}while(choice != 4);			
}
	



void main(void)

{
	

	menu();
	
}

If you change the function definitions, then you should change the way you call them also. Correct the places I have highlighted in Red.
And why aren't you using the Node* cur element in the addprocess function? You have to use it if you want to link the processes to a link list that you have a handle to. I think it should be the header node of the linked list.

i have figured it out!!!
how would i be able to center the menu in the center of the screen?

#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
#include <process.h>


struct Node
{
	PROCESS_INFORMATION p;
	Node *next;
};
Node* head = NULL;



void menu (void)
{ int choice;
	do
	{
		system("cls");
		cout << "                      ---1.  Calculator ---" << endl;
		cout << "                      ---2.  Notepad    ---" << endl;
		cout << "                      ---3.  Paint      ---"<< endl;
		cout << "                      ---4.  Terminate  ---" << endl;
		cin >> choice;
	
	
					char lpApplicationName[100];
					STARTUPINFO StartInfo;
					PROCESS_INFORMATION ProcessInfo;					
					ZeroMemory(&StartInfo, sizeof(StartInfo));
					StartInfo.cb = sizeof(StartInfo);
						if(choice == 1)
					{
						CreateProcess ("C:\\Windows\\system32\\calc.exe", NULL, NULL, NULL, FALSE, HIGH_PRIORITY_CLASS|CREATE_NEW_CONSOLE, NULL, NULL, &StartInfo, &ProcessInfo);	

			Node *t;
			t = new(Node);
			t->p = ProcessInfo;
			t->next = head;
			head = t;
					
					}
						if(choice == 2)
						{
							CreateProcess ("C:\\Windows\\system32\\Notepad.exe", NULL, NULL, NULL, FALSE, HIGH_PRIORITY_CLASS|CREATE_NEW_CONSOLE, NULL, NULL, &StartInfo, &ProcessInfo);		
							Node *t;
							t = new(Node);
							t->p = ProcessInfo;
							t->next = head;
							head = t;						}
						if(choice == 3)
						{
							CreateProcess ("C:\\Windows\\system32\\mspaint.exe", NULL, NULL, NULL, FALSE, HIGH_PRIORITY_CLASS|CREATE_NEW_CONSOLE, NULL, NULL, &StartInfo, &ProcessInfo);		
							Node *t;
							t = new(Node);
							t->p = ProcessInfo;
							t->next = head;
							head = t;	
						}
						if (choice == 4)
						{
							Node* t;
							t = head;	
							while(t != NULL)
							{
								
								TerminateProcess(t->p.hProcess, 0);
								t = t->next;
							}
						}
						
		
	}while(choice != 4);			
}
	



void main(void)

{
	

	menu();
	
}

Sine you are working in console mode it is a bit involved. Refer this page. It has the necessary functions to get the console window dimensions. You will have to calculate the required text position depending on the console width and height and then output the menu accordingly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.