1 | -DEBUG:FULL -Zi -Od -MP -MTd -LD dll_source.c -Fmdll_source.map |
1 | -DEBUG:FULL -Zi -Od -MP |
1 | cl.exe ...clarguments... -link -DEBUG:FULL |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | #include <windows.h> static int GlobalRunning; LRESULT MainCallbak(HWND Window ,UINT Message ,WPARAM WParam ,LPARAM LParam) { LRESULT Result = 0; switch(Message) { case WM_DESTROY: case WM_QUIT: { GlobalRunning = 0; } break; default: { Result = DefWindowProc(Window ,Message ,WParam ,LParam); } break; break; } return (Result); } int WINAPI wWinMain(HINSTANCE Instance, HINSTANCE PrevInstance, PWSTR CmdLine, int CmdShow) { const char WindowClassName[] = "TestWindowClass"; const char WindowTitle[] = "Test"; WNDCLASS WindowClass = {0}; WindowClass.style = CS_HREDRAW | CS_VREDRAW; WindowClass.lpfnWndProc = MainCallbak; WindowClass.hInstance = Instance; WindowClass.lpszClassName = WindowClassName; RegisterClass(&WindowClass); HWND WindowHandle = CreateWindowEx(0, WindowClassName, WindowTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT ,CW_USEDEFAULT, CW_USEDEFAULT ,CW_USEDEFAULT, 0, 0, Instance, 0); // ----------------------------------- typedef int (*UPDATE_FUNCTION)(void); HMODULE OtherCode = LoadLibraryA("test.dll"); UPDATE_FUNCTION ExternalUpdateFunction = (UPDATE_FUNCTION) GetProcAddress(OtherCode ,"SomeUpdateFunction"); // ----------------------------------- GlobalRunning = 1; ShowWindow(WindowHandle ,SW_SHOW); while(GlobalRunning) { MSG Message = {0}; while(PeekMessageA(&Message ,0 ,0 ,0 ,PM_REMOVE)) { switch(Message.message) { case WM_DESTROY: case WM_QUIT: { GlobalRunning = 0; } break; default: { TranslateMessage(&Message); DispatchMessage(&Message); } break; } } GlobalRunning = ExternalUpdateFunction(); Sleep(5); } return 0; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 | int SomeUpdateFunction() { static int SomeCounter = 0; int BreakHere = 22; if(BreakHere >= 20) { BreakHere++; } return (SomeCounter++ < 200); } |
1 2 3 4 5 6 7 8 9 10 11 | @echo off set CompilerFlags=-Zi -nologo -Od -MP pushd build\ cl %CompilerFlags% -MTd -LD ..\src\test.c -Fmtest.map -link -DEBUG:FULL -INCREMENTAL:no -EXPORT:SomeUpdateFunction cl %CompilerFlags% ..\src\win32_test.c -link -INCREMENTAL:no -DEBUG:FULL -out:test.exe user32.lib gdi32.lib popd |