Windows System Programming Kernel Object Object Handle Tutor
Windows System Programming -Kernel Object & Object Handle- Tutor: 20060106 배문희
커널 오브젝트(Kernel Object) 실습 • Calculator 1. cpp • 과제: calculator 1. cpp 수정 2009 -04 -01 호남대학교 정보통신공학과 10
#include<stdio. h> #include<tchar. h> #include<windows. h> enum{DIV=1, MUL, ADD, MIN, ELSE, EXIT}; DWORD Show. Menu(); void Divide(double, double); void Multiple(double, double); void Add(double, double); void Min(double, double); DWORD Show. Menu(){ DWORD sel; _fputts(_T("-----Menu----- n"), stdout); _fputts(_T("num 1: Divide n"), stdout); _fputts(_T("num 2: Multiple n"), stdout); _fputts(_T("num 3: Add n"), stdout); _fputts(_T("num 4: Minus n"), stdout); _fputts(_T("num 5: Any other operations. n"), stdout); _fputts(_T("num 6: Exit n"), stdout); _fputts(_T("SELECTION >>"), stdout); _tscanf(_T("%d"), &sel); return sel; } _tmain() void Divide(double a, double b){ _tprintf(_T("%f/%f=%f nn"), a, b, a/b); } void Multiple(double a, double b){ _tprintf(_T("%f*%f=%f nn"), a, b, a*b); } void Add(double a, double b){ _tprintf(_T("%f+%f=%f nn"), a, b, a+b); } void Min(double a, double b){ _tprintf(_T("%f-%f=%f nn"), a, b, a-b); } 2009 -04 -01 호남대학교 정보통신공학과 11
int _tmain(int argc, TCHAR* argv[]) { STARTUPINFO si = {0, }; PROCESS_INFORMATION pi; si. cb = sizeof(si); TCHAR command[] = _T("C: \WINDOWS\system 32\calc. exe"); DWORD sel; double num 1, num 2; while(true) { sel = Show. Menu(); if(sel == EXIT) return 0; if(sel != ELSE){ _fputts(_T("Input Num 1 Num 2: "), stdout); _tscanf(_T("%lf %lf"), &num 1, &num 2); } switch(sel) { case DIV: Divide(num 1, num 2); break; case MUL: Multiple(num 1, num 2); break; case ADD: Add(num 1, num 2); break; case MIN: Min(num 1, num 2); break; case ELSE: Zero. Memory(&pi, sizeof(pi)); Create. Process(NULL, command, NULL, TRUE, 0, NULL, &si, &pi); break; } } } return 0; 2009 -04 -01 호남대학교 정보통신공학과 12
- Slides: 16