카테고리 없음
BasicApp소스이다.
잠수함토끼
2008. 8. 30. 11:17
#undef UNICODE #includechar g_szAppName[]="Basic GUI Application"; LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM); int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hpreInstance, LPSTR lpCmdLine, int nShowCmd) { HWND hwnd; MSG msg; WNDCLASS wndclass; wndclass.style=CS_HREDRAW|CS_VREDRAW; wndclass.lpfnWndProc=WndProc; wndclass.cbClsExtra=0; wndclass.cbWndExtra=0; wndclass.hInstance=hinst; wndclass.hIcon = LoadIcon(NULL,IDI_APPLICATION); wndclass.hCursor = LoadCursor(NULL,IDC_ARROW); wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wndclass.lpszMenuName=NULL; wndclass.lpszClassName=g_szAppName; if(!RegisterClass(&wndclass)) { MessageBox(NULL,"Windows class Registeration Failure!!!!",g_szAppName,MB_OK); return 0; } hwnd=CreateWindow(g_szAppName, //윈도우 클래스 네임 g_szAppName, //윈도우 캡션 WS_OVERLAPPEDWINDOW,//윈도우 스타일 CW_USEDEFAULT, //초기 x값 CW_USEDEFAULT, //초기 y값 400, //초기 X 크기 150, //초기 y 크기 NULL, //부모 윈도우 핸들 NULL, //윈도우 메뉴 핸들 hinst,//프로그램 인스턴스 핸들 NULL);//발생 파라미터 if(!hwnd){ MessageBox(NULL,"Windows Creation Failure!!!!",g_szAppName,MB_OK); return 0; } ShowWindow(hwnd,nShowCmd); UpdateWindow(hwnd); while (GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam; } LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { static char szOutBuf[]="The Most Simple Windows GUI Program by YHD"; HDC hdc; PAINTSTRUCT ps; RECT rect; switch (uMsg) { case WM_PAINT: hdc=BeginPaint(hwnd,&ps); GetClientRect(hwnd,&rect); DrawText(hdc, szOutBuf,lstrlen(szOutBuf),&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER); EndPaint(hwnd,&ps); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd,uMsg,wParam,lParam); }
하나의 Process 구성 = One( EXE ) + Many( DLL )
EXE와 DLL은 같은 구조이다. MZ로 시작한다.
프로그램 로더: 정의: Win32 운영체제의 서브시스템,
하는 일: EXE 파일을 로드 함
일하는 방식: EXE의 파일 구조를 식별하여 로드 함
Image: 정의: 메모리에 매핑된 PE포맷 자체이다. (MMF)