主题:本人是C++的新手,大家能解释一下这个程序吗?
#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();
}
本人是C++的新手,大家能解释一下这个程序吗?还有就是有没有可能把以上的程序转化成GUI MFC?
#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();
}
本人是C++的新手,大家能解释一下这个程序吗?还有就是有没有可能把以上的程序转化成GUI MFC?