Click here to Skip to main content
15,915,324 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to check if a reference is NULL Pin
S. Senthil Kumar7-Apr-05 22:13
S. Senthil Kumar7-Apr-05 22:13 
QuestionHow to HitTest an item of a List Ctrl owned by another thread Pin
Luckybird7-Apr-05 16:23
Luckybird7-Apr-05 16:23 
AnswerRe: How to HitTest an item of a List Ctrl owned by another thread Pin
Ryan Binns7-Apr-05 18:18
Ryan Binns7-Apr-05 18:18 
GeneralRe: How to HitTest an item of a List Ctrl owned by another thread Pin
Luckybird7-Apr-05 23:29
Luckybird7-Apr-05 23:29 
GeneralRe: How to HitTest an item of a List Ctrl owned by another thread Pin
Ryan Binns8-Apr-05 2:12
Ryan Binns8-Apr-05 2:12 
Generalpliz help me with input validation Pin
mpapeo7-Apr-05 15:05
mpapeo7-Apr-05 15:05 
GeneralRe: pliz help me with input validation Pin
Christian Graus7-Apr-05 15:14
protectorChristian Graus7-Apr-05 15:14 
GeneralRe: pliz help me with input validation Pin
Anonymous7-Apr-05 15:35
Anonymous7-Apr-05 15:35 
This is what i have,
<code>
#include <windows.h>
#include <stdio.h>
#include <windef.h>
#include <winbase.h>
#include <imagehlp.h>
#include <stdlib.h>
#include <ctype.h>
typedef struct _iobuf FILE;
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>

int menu(void)
{
char iobuf[80];
int choice;
int i,len,valid;
printf ("\n");
printf ("*****************************************\n");
printf ("*\t\t\t\t\t*\n*\tPROCESS CREATION \t\t*\n");
printf ("=========================================");
printf ("\n=\t 1: Create a process \t\t=");
printf ("\n=\t 2: Suspend the process\t\t=");
printf ("\n=\t 3: Resume process \t=");
printf ("\n=\t 4: Shutdown the process \t=");
printf ("\n=========================================\n");
printf ("\n");

printf("\nEnter choice (1-4): ");
valid = 0;
while( valid == 0)
{
fgets(iobuf,sizeof(iobuf),stdin);
// remove '\n'
len = strlen(iobuf)-1;
iobuf[len] = 0;
// validate data
valid = 1; // assume valid input
for(i = 0; i < len; i++)
{
if( !isdigit(iobuf[i]))
{
printf("\nPlese enter numeric digits only (1-4)\n");
valid = 0;
}
}
}
choice = atoi(iobuf);


//scanf("%d", &choice);
return choice;
}
int main(int argc, char **argv)
{
PROCESS_INFORMATION pi; /* filled in by CreateProcess */
STARTUPINFO si; /* startup info for the new process*/
HANDLE hProcess;
DWORD lpAddr = 0;
TCHAR lpApplicationName[_MAX_PATH]="";
int result;
char ans [4]="";
int choice;
while((choice = menu())!=5)//int choice;
{
switch (choice)
{
case 1:
GetStartupInfo(&si);
lpAddr = 0;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
printf("Enter process you want to execute: ",lpApplicationName);
scanf ("%s",lpApplicationName);
printf("Process %d reporting for creation\n",GetCurrentProcessId());//print out our process ID

CreateProcess(NULL, /* lpApplicationName */
lpApplicationName, /* lpCommandLine assumes to use curent process directory*/
NULL, /* lpsaProcess */
NULL, /* lpsaThread */
FALSE, /* bInheritHandles */
CREATE_NEW_CONSOLE, /* dwCreationFlags */
NULL, /* lpEnvironment */
NULL, /* lpCurDir */
&si, /* lpStartupInfo */
&pi /* lpProcInfo */
);
hProcess = pi.hProcess;
printf("New Process ID: %d ",pi.dwProcessId);
printf("has started \n");
break;
case 2:
SuspendThread(pi.hProcess);// identifies thread to suspend
break;
case 3:
ResumeThread(pi.hProcess);
break;
case 4:
printf("\nYou are about to terminate a running process, do you want to continue ( y or n) ");
scanf ("%s",ans);

result = strcmp(ans,"y");

if (result==0)
{
TerminateProcess(pi.hProcess, 0);//identifies the process to terminate
GetLastError();
}
break;

default:
printf("\nInvalid choice: ");
}
}
return (0);
}

</code>
GeneralRe: pliz help me with input validation Pin
Christian Graus7-Apr-05 15:39
protectorChristian Graus7-Apr-05 15:39 
GeneralRe: pliz help me with input validation Pin
mpapeo7-Apr-05 15:50
mpapeo7-Apr-05 15:50 
GeneralRe: pliz help me with input validation Pin
Christian Graus7-Apr-05 15:52
protectorChristian Graus7-Apr-05 15:52 
GeneralRe: pliz help me with input validation Pin
mpapeo8-Apr-05 1:48
mpapeo8-Apr-05 1:48 
GeneralRe: pliz help me with input validation Pin
David Crow8-Apr-05 5:29
David Crow8-Apr-05 5:29 
GeneralRe: pliz help me with input validation Pin
LighthouseJ7-Apr-05 15:48
LighthouseJ7-Apr-05 15:48 
GeneralRe: pliz help me with input validation Pin
mpapeo7-Apr-05 15:59
mpapeo7-Apr-05 15:59 
GeneralRe: pliz help me with input validation Pin
mpapeo7-Apr-05 16:21
mpapeo7-Apr-05 16:21 
Generalemulating commands in c++ Pin
Jeb997-Apr-05 14:32
Jeb997-Apr-05 14:32 
GeneralRe: emulating commands in c++ Pin
Christian Graus7-Apr-05 15:14
protectorChristian Graus7-Apr-05 15:14 
QuestionWhere to download a crystal report tool from? Pin
awasthy7-Apr-05 13:52
awasthy7-Apr-05 13:52 
AnswerRe: Where to download a crystal report tool from? Pin
liquid_8-Apr-05 7:13
liquid_8-Apr-05 7:13 
GeneralUnhandled Exception. Pin
blinkered7-Apr-05 11:28
blinkered7-Apr-05 11:28 
GeneralRe: Unhandled Exception. Pin
Shaileshhex22-Jul-08 1:50
Shaileshhex22-Jul-08 1:50 
Generalflat toolbar in WinXP Pin
BaShOr7-Apr-05 10:27
BaShOr7-Apr-05 10:27 
GeneralRe: flat toolbar in WinXP Pin
Mark Salsbery15-Nov-06 11:32
Mark Salsbery15-Nov-06 11:32 
GeneralHelp with a school project Pin
diegomiami7-Apr-05 10:02
diegomiami7-Apr-05 10:02 

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.