#include "pch.h"
#include "framework.h"
#include "Ex_974p_ReadFile.h"
LPCTSTR MyClassName = TEXT("ReadFile");
HINSTANCE g_hInst{};
HWND hWndMain{};
TCHAR buf[1024]{};
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow) {
HWND hWnd{};
MSG msg{};
WNDCLASSEXW wndclassexw{};
g_hInst = hInstance;
wndclassexw.lpfnWndProc = WndProc;
wndclassexw.hInstance = hInstance;
wndclassexw.lpszClassName = MyClassName;
wndclassexw.hIconSm = NULL;
wndclassexw.cbSize = sizeof(WNDCLASSEX);
wndclassexw.cbClsExtra = 0;
wndclassexw.cbWndExtra = 0;
wndclassexw.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndclassexw.hIcon = LoadIconW(NULL, IDI_APPLICATION);
wndclassexw.hCursor = LoadCursorW(NULL, IDC_ARROW);
wndclassexw.lpszMenuName = NULL;
wndclassexw.style = CS_VREDRAW | CS_HREDRAW;
RegisterClassExW(&wndclassexw);
hWnd = CreateWindowExW(NULL, MyClassName, MyClassName, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, (HMENU)NULL, hInstance, NULL);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
while (GetMessageW(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
return((int)msg.wParam);
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) {
HDC hdc{};
PAINTSTRUCT ps{};
HANDLE hFile{};
DWORD dwRead{};
RECT rt{};
switch (iMessage) {
case WM_LBUTTONDOWN:
hFile = CreateFile(L"Test.txt", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE) {
if (ReadFile(hFile, buf, 1024, &dwRead, NULL)) {
CloseHandle(hFile);
InvalidateRect(hWnd, NULL, TRUE);
}
}
return(0);
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rt);
DrawText(hdc, buf, -1, &rt, DT_WORDBREAK);
EndPaint(hWnd, &ps);
return(0);
case WM_DESTROY:
PostQuitMessage(0);
return(0);
}
return(DefWindowProcW(hWnd, iMessage, wParam, lParam));
}
------------------------------------------------------------------------------------------------------------------------------------------
À§ ¿¹Á¦¸¦ ½ÇÇàÇÒ ½Ã Test.txtÆÄÀÏÀ» Àоî¿Ã ½Ã ÇѱÛÀÌ ±úÁö´Â Çö»óÀÌ ³ªÅ¸³³´Ï´Ù.
¿µ¾î·Î ÅØ½ºÆ® ÆÄÀÏÀ» ÀúÀåÇØµµ ¸¶Âù°¡Áö·Î ±úÁü´Ï´Ù.
ÅØ½ºÆ® ÆÄÀÏÀ» ÀоîµéÀÏ ½Ã ±úÁöÁö ¾Ê°Ô ÇϱâÀ§ÇØ ¾î¶»°Ô ÇØ¾ßÇÏ´ÂÁö ±Ã±ÝÇÕ´Ï´Ù.

±è¹Î¼ö
403 Forbidden403 Forbidden |
|