Click here to Skip to main content
15,897,273 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Creating resources in Chinese Pin
Phil J Pearson23-Mar-05 3:38
Phil J Pearson23-Mar-05 3:38 
GeneralRe: Creating resources in Chinese Pin
Sheng Jiang 蒋晟23-Mar-05 5:24
Sheng Jiang 蒋晟23-Mar-05 5:24 
GeneralAdding scrollbars in custom static control Pin
Binsan22-Mar-05 23:33
Binsan22-Mar-05 23:33 
GeneralRe: Adding scrollbars in custom static control Pin
Monty223-Mar-05 2:21
Monty223-Mar-05 2:21 
GeneralSHA Encription Pin
Anand for every one22-Mar-05 23:05
Anand for every one22-Mar-05 23:05 
GeneralRe: SHA Encription Pin
Chris Losinger23-Mar-05 1:07
professionalChris Losinger23-Mar-05 1:07 
GeneralRe: SHA Encription Pin
Alexander M.,23-Mar-05 12:28
Alexander M.,23-Mar-05 12:28 
Generalprogram crushes!! Pin
mpapeo22-Mar-05 22:56
mpapeo22-Mar-05 22:56 
I have a little menu here which i want to execute my functions using it.
So i have problems in entering the process like notepad which i want to create, but then it crushes.
How can i declare the variable which will take care of the input process, because i didn't want to include it in the commandline when running. Part of my code is below
<br />
#include <windows.h><br />
#include <stdio.h><br />
#include <windef.h><br />
#include <winbase.h><br />
#include <imagehlp.h>   <br />
LPVOID lpMsgBuf;<br />
<br />
int menu(void)<br />
{<br />
int choice;<br />
<br />
	 printf ("\n");<br />
	 printf ("*****************************************\n");<br />
	 printf ("*\t\t\t\t\t*\n*\tCHECKPOINTING SYSTEM \t\t*\n");<br />
	 printf ("=========================================");<br />
	 printf ("\n=\t 1: Create a process    \t=");<br />
	 printf ("\n=\t 2: Shutdown the process\t=");<br />
	 printf ("\n=========================================\n");<br />
	 printf ("\n");<br />
<br />
	 printf("\nEnter choice (1-2): ");<br />
	 scanf("%d", &choice);<br />
	 return choice;	<br />
}<br />
int main(int argc, char **argv) <br />
{<br />
	PROCESS_INFORMATION pi ;       /* filled in by CreateProcess */<br />
	STARTUPINFO si;               /* startup info for the new process*/<br />
	LPDWORD lpExitCode = 0;<br />
	HANDLE hProcess ; <br />
	DWORD baseaddr = 0;<br />
	DWORD error = GetLastError();<br />
	LPCTSTR lpApplicationName="";<br />
<br />
int choice;<br />
menu();<br />
<br />
while((choice = menu())!=3)<br />
{<br />
switch (choice)<br />
{<br />
case 1:					<br />
printf("Enter process you want to execute: ",lpApplicationName);<br />
scanf ("%s",lpApplicationName);<br />
printf("Process %d reporting for creation\n",GetCurrentProcessId());//print out our process ID<br />
GetStartupInfo(&si);<br />
CreateProcess(NULL,		/* lpApplicationName */<br />
argv[1],          /* lpCommandLine  assumes to use curent process directory*/<br />
NULL,					/* lpsaProcess */<br />
NULL,					/* lpsaThread */<br />
FALSE,					/* bInheritHandles */<br />
CREATE_NEW_CONSOLE,     /* dwCreationFlags */<br />
NULL,					/* lpEnvironment */<br />
NULL,					/* lpCurDir */<br />
&si,					/* lpStartupInfo */<br />
&pi						/* lpProcInfo */<br />
);  <br />
  hProcess = pi.hProcess;<br />
  printf("New Process ID: %d ",pi.dwProcessId);<br />
  printf("has started \n"); <br />
break;<br />
case 2:<br />
<br />
TerminateProcess(pi.hProcess, GetExitCodeProcess(hProcess,lpExitCode ));<br />
GetLastError();<br />
<br />
break;<br />
default: printf("\nInvalid choice: ");<br />
}//while<br />
}<br />
return(0);<br />
}<br />


oam
GeneralRe: program crushes!! Pin
Hans Ruck23-Mar-05 1:20
Hans Ruck23-Mar-05 1:20 
GeneralRe: program crushes!! Pin
mpapeo23-Mar-05 1:32
mpapeo23-Mar-05 1:32 
GeneralRe: program crushes!! Pin
Hans Ruck23-Mar-05 1:39
Hans Ruck23-Mar-05 1:39 
GeneralRe: program crushes!! Pin
mpapeo23-Mar-05 1:48
mpapeo23-Mar-05 1:48 
GeneralRe: program crushes!! Pin
Hans Ruck23-Mar-05 2:48
Hans Ruck23-Mar-05 2:48 
GeneralRe: program crushes!! Pin
mpapeo23-Mar-05 7:15
mpapeo23-Mar-05 7:15 
GeneralRe: program crushes!! Pin
mpapeo23-Mar-05 9:55
mpapeo23-Mar-05 9:55 
Questionhow to delete a string from a file? Pin
nehathoma22-Mar-05 22:47
nehathoma22-Mar-05 22:47 
AnswerRe: how to delete a string from a file? Pin
ThatsAlok23-Mar-05 0:07
ThatsAlok23-Mar-05 0:07 
GeneralRe: how to delete a string from a file? Pin
nehathoma23-Mar-05 0:21
nehathoma23-Mar-05 0:21 
GeneralRe: how to delete a string from a file? Pin
ThatsAlok23-Mar-05 1:01
ThatsAlok23-Mar-05 1:01 
GeneralRe: how to delete a string from a file? Pin
David Crow23-Mar-05 2:34
David Crow23-Mar-05 2:34 
GeneralMissing MFC Headers in Visual C++ 2005 express Pin
Ger Hayden22-Mar-05 22:34
Ger Hayden22-Mar-05 22:34 
GeneralRe: Missing MFC Headers in Visual C++ 2005 express Pin
Sheng Jiang 蒋晟23-Mar-05 5:13
Sheng Jiang 蒋晟23-Mar-05 5:13 
GeneralPreventing a View from being Closed Pin
RobHayles22-Mar-05 21:34
RobHayles22-Mar-05 21:34 
GeneralRe: Preventing a View from being Closed Pin
Abyss22-Mar-05 21:44
Abyss22-Mar-05 21:44 
GeneralRe: Preventing a View from being Closed Pin
RobHayles24-Mar-05 1:30
RobHayles24-Mar-05 1:30 

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.