Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

mpapeo

@mpapeo
About
Posts
72
Topics
23
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • menu and sub menu
    M mpapeo

    Christian Graus wrote: Error 2 - I don't understand. It won't shut down if you type 'y' ? If i choose optio 8, it will output; Are you sure you want to quit the system(y or n): n if no is entered then the output is "You have entered an invalid command, check the menu below" and displays menu instead it should display the menu only -oam-

    C / C++ / MFC help career

  • menu and sub menu
    M mpapeo

    Error 1: It does not validate properly: option 2-6 should not run before option 1. All these option crushes the program Error 2: It executes the default of the case statement if the user enter "no" if does not want to shutdown the program -oam-

    C / C++ / MFC help career

  • menu and sub menu
    M mpapeo

    Christian Graus wrote: First trick of programming - if it crashes, work out why, don't just change to a lesser design Yes i am working on it day and night but now i am under presure as i have to submit this tommorrow. #include #include #include #include #include typedef struct _iobuf FILE; #include #include #include #include int menu(void) { //int choice; char iobuf[80]; int i,len,valid; HANDLE hProcess; printf ("\n"); printf ("\t\t\t*****************************************\n"); printf ("\t\t\t*\t\t\t\t\t*\n\t\t\t*\t\tPROCESS\t\t\t*\n"); printf ("\t\t\t*\t\t\t\t\t*\n\t\t\t* CHECKPOINTING AND MIGRATION SYSTEM\t*\n"); printf ("\t\t\t*\t\t\t\t\t*\n"); printf ("\t\t\t========================================="); printf ("\n\t\t\t=\t 1: Create a Process \t="); printf ("\n\t\t\t=\t 2: Suspend Process \t="); printf ("\n\t\t\t=\t 3: Resume Process \t="); printf ("\n\t\t\t=\t 4: Shutdown Process\t\t="); printf ("\n\t\t\t=\t 5: Checkpoint Process\t\t="); printf ("\n\t\t\t=\t 6: Restart Process\t\t="); printf ("\n\t\t\t=\t 7: Help \t\t\t="); printf ("\n\t\t\t=\t 8: Quit the system\t\t="); printf ("\n\t\t\t=========================================\n"); printf ("\n"); printf("\n\t\t\tEnter choice (1-8): "); valid = 0; while( valid == 0) { fgets(iobuf,sizeof(iobuf),stdin); len = strlen(iobuf)-1; iobuf[len] = 0;// the input/output buffer for storing characters // validate data valid = 1; // assume valid input for(i = 0; i < len; i++) //loop controlling invalid input { if( !isdigit(iobuf[i])) { printf("\n\t\t\tPlese enter numeric digits only (1-8):"); valid = 0; } } }//while hProcess = atoi(iobuf); return hProcess; }//menu HWND g_hWnd = NULL; BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam) { DWORD dwProcID; GetWindowThreadProcessId(hwnd,&dwProcID); if(dwProcID == (DWORD)lParam) { //this hwnd is the top level window ofthe process g_hWnd = hwnd; } return TRUE; } int main(int argc, char **argv) { FILE* fp; //char fname[20]; char ans[4]; int result; PROCESS_INFORMATION pi; /* filled in by CreateProcess */ STARTUPINFO si; /* startup info for the new process*/ HANDLE hProces

    C / C++ / MFC help career

  • menu and sub menu
    M mpapeo

    Well i wanted to go with your suggestion but then i have the program crushing and i have already intergrated my code it is now large. But even the submenu one that i am thinking above cannot confuse user's of the system if it is used. -oam-

    C / C++ / MFC help career

  • menu and sub menu
    M mpapeo

    I want to create a submenu which uses the case statements. So my problem is the program crushes and i can't get the logic how i can arrange the case statements. Please help me, i am already under pressure because of time. I want the program run such that if i enter option 1 it create a process and then produce which i can now suspend the process from there or shut it down in the submenu Here is my code #include #include #include #include #include #include #include typedef struct _iobuf FILE; #include #include #include int menu(void) { char iobuf[80]; int choice; int i,len,valid; //HANDLE hProcess; 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: Quit the system\t\t="); printf ("\n=========================================\n"); valid=0; printf("\nEnter choice (1-3): "); 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-5)\n"); valid = 0; } } } choice = atoi(iobuf); return choice; } int submenu(void) { char iobuf[80]; int choice2; int i,len,valid; //HANDLE hProcess; 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; printf ("\n*****************************************\n"); printf ("*\t\t\t\t\t*\n*\tPROCESS CREATION \t\t*\n"); printf ("========================================="); printf ("\n=\t 1: Suspend the process\t\t="); printf ("\n=\t 2: Resume process \t="); printf ("\n=\t 3: Shutdown the process \t="); printf ("\n=\t 4: Exit the system \t="); printf ("\n=========================================\n"); printf ("\n"); valid=0; printf("\nEnter choice (1-4): "); while( valid == 0) { fgets(iobuf,sizeof(iobuf),stdin); // remove '\n' len = strlen(iobuf)-1; iobuf[len] = 0;

    C / C++ / MFC help career

  • Process handling
    M mpapeo

    Mark Petrik Sosa wrote: Perhaps make sure that these calls are succeeding by checking the return values. If you wanted to keep track of more then one process then you could use a container class like MFC's CArray or CList or STL's vector or list. I don't have any idea about MFC arrays because i am using C unless if they can work in c code. But i have no idea with MFC or CList nor STL vector. You can give me a go ahead or segment code to handle it -oam-

    C / C++ / MFC question

  • Process handling
    M mpapeo

    Well my question lies in how to specify the handle or the process id of one the processes i have created to shut it down or suspend it that particular process. Pliz give me a segment code if you have. #include #include #include #include #include #include typedef struct _iobuf FILE; #include #include #include int menu(void) { int choice; printf ("\n"); printf ("*****************************************\n"); printf ("*\t\t\t\t\t*\n*\tCHECKPOINTING SYSTEM \t\t*\n"); printf ("========================================="); printf ("\n=\t 1: Create a process \t="); printf ("\n=\t 2: Suspend the process\t="); printf ("\n=\t 3: Resume the process\t=");//recreate the process printf ("\n=\t 4: System Information\t="); printf ("\n=========================================\n"); printf ("\n"); printf("\nEnter choice (1-4): "); 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; HANDLE hThread = 0; DWORD NumberOfBytesRead = 0; DWORD baseaddr = 0; DWORD lpAddr = 0; PMEMORY_BASIC_INFORMATION lpBuffer = 0; DWORD dwLength = 200000; DWORD flNewProtect =0; PDWORD lpflOldProtect = 0; DWORD dwSize =0; LPCVOID lpBaseAddress = 0; DWORD nSize = 0; // MEMORY_BASIC_INFORMATION mbi; LPDWORD lpNumberOfBytesWritten = 0; TCHAR lpApplicationName[_MAX_PATH]=""; SYSTEM_INFO sinfo; LPDWORD lpExitCode = 0; // DWORD pid; // LPVOID base; HWND hWnd = 0; DWORD dwProcessID = 0; UINT GetBase(); LPCONTEXT lpContext = 0; //CONST CONTEXT *lpContext; int nRet = 0; // char *state; unsigned int regnum = 0; //******************************************** char* ans=""; int choice; while((choice = menu())!=5) { 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

    C / C++ / MFC question

  • Process handling
    M mpapeo

    I have my small program which creates process, but now i want to manipulate more than one process at a time. Is that possible? Like i have created a notepad process and later while notepad is running i create another process cmd.exe, can i suspend them all one after the other or shut them consecutively maybe by specifying process id,s or handles -oam-

    C / C++ / MFC question

  • pliz help me with input validation
    M mpapeo

    I stil have the program crushing, i might be missing something 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; } } } hProcess = atoi(iobuf); //scanf("%d", &choice); return hProcess;//choice; } -oam-

    C / C++ / MFC help career

  • pliz help me with input validation
    M mpapeo

    I still have the program crashing -oam-

    C / C++ / MFC help career

  • pliz help me with input validation
    M mpapeo

    let me try chris method first -oam- seems as that im having slight problems why does it takes default now after pass the hProcess

    C / C++ / MFC help career

  • pliz help me with input validation
    M mpapeo

    You mean passing it as an input? -oam-

    C / C++ / MFC help career

  • pliz help me with input validation
    M mpapeo

    i have been try it out but failed. The second and third options should only be executed when there is a process running. But now i fail to write that error message so the user does not suspend a process while there is no process running. part of my code is below 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; -oam-

    C / C++ / MFC help career

  • validate email address
    M mpapeo

    The code i was looking for is here[^] -oam-

    Web Development

  • validate email address
    M mpapeo

    Any one with a piece of code to validate the email address like @ sign and the . -oam-

    Web Development

  • header file
    M mpapeo

    Well i was interested in the code i sent before as it was running in unix but it is possible run it on windows platform. I wanted to use that code somewhere in one of my programs Any help pliz -oam-

    C / C++ / MFC help

  • header file
    M mpapeo

    Did you check the code i sent there headers are #include /* has definitions of printf, fprintf, fopen, fscanf, fclose, fflush, perror, rename and BUFSIZ */ #include /* has definitions of getenv and exit */ #include /* has definition of sleep */ #include /* has definitions of strcpy and strcat */ therefore i thought the header file will take care of the definition of sleep and that there header file is standard like some headers files that you can get them from somewhere and use them -oam-

    C / C++ / MFC help

  • header file
    M mpapeo

    infact i wanted to compile this code below but now i am working hand in hand with unix machines. But now i wanted to try this application on windows #include /* has definitions of printf, fprintf, fopen, fscanf, fclose, fflush, perror, rename and BUFSIZ */ #include /* has definitions of getenv and exit */ #include /* has definition of sleep */ #include /* has definitions of strcpy and strcat */ main() { char *restart_name, *restart, old_restart_name[BUFSIZ]; FILE *restart_file; int n; /* Is this a continued job or a new one? */ if (! (restart = getenv ("RSAVE_RESTART"))) { printf ("Starting a new run.\n"); n = 0; } else { if (! (restart_name = getenv ("RSAVE_CHECKFILE"))) { fprintf (stderr, "error: no checkpoint file for the restart job\n"); exit (1); } else { printf ("Restarting the job from %s.\n", restart_name); if (! (restart_file = fopen(restart_name, "r"))) { perror (restart_name); exit (2); } else { if (! (fscanf (restart_file, "%d", &n) > 0)) { fprintf (stderr, "%s: input file format error\n", restart_name); exit (3); } else { fclose (restart_file); } } } } printf ("n = %d\n", n); printf ("\tcomputing ... "); fflush (stdout); sleep (5); n++; printf ("done.\n"); printf ("n = %d\n", n); if (! (restart_name = getenv ("RSAVE_CHECKFILE"))) { printf ("checkpointing not requested, exiting...\n"); exit (0); } else { if (restart) { strcpy (old_restart_name, restart_name); strcat (old_restart_name, ".old"); printf ("renaming old restart file to %s\n", old_restart_name); if (0 > rename (restart_name, old_restart_name)) { perror (old_restart_name); exit (4); } } printf ("saving data on %s\n", restart_name); if (! (restart_file = fopen (restart_name, "w"))) { perror (restart_name); exit (5); } else { fprintf (restart_file, "%d\n", n); fclose (restart_file); } } exit (0); } -oam-

    C / C++ / MFC help

  • header file
    M mpapeo

    I am running an application on windows from a unix machine and it was looking for this header but then i didn't want to go to the unix machine -oam-

    C / C++ / MFC help

  • header file
    M mpapeo

    Sory i thought i posted it #include unistd.h thanx -oam-

    C / C++ / MFC help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups