| OLD | NEW |
| (Empty) |
| 1 //========================================== | |
| 2 // LIBCTINY - Matt Pietrek 2001 | |
| 3 // MSDN Magazine, January 2001 | |
| 4 // FILE: CRT0TWIN.CPP | |
| 5 //========================================== | |
| 6 #include "libctiny.h" | |
| 7 #include <windows.h> | |
| 8 #include "initterm.h" | |
| 9 | |
| 10 // Force the linker to include KERNEL32.LIB | |
| 11 #pragma comment(linker, "/defaultlib:kernel32.lib") | |
| 12 | |
| 13 #pragma comment(linker, "/nodefaultlib:libc.lib") | |
| 14 #pragma comment(linker, "/nodefaultlib:libcmt.lib") | |
| 15 | |
| 16 // Modified version of the Visual C++ startup code. Simplified to | |
| 17 // make it easier to read. | |
| 18 | |
| 19 extern int WINAPI WinMain(HINSTANCE hinstExe, HINSTANCE hinstPrev, | |
| 20 LPSTR pszCmdLine, int nCmdShow); | |
| 21 | |
| 22 extern "C" void __cdecl WinMainCRTStartup() { | |
| 23 int mainret; | |
| 24 char *lpszCommandLine; | |
| 25 STARTUPINFO StartupInfo; | |
| 26 | |
| 27 lpszCommandLine = GetCommandLine(); | |
| 28 | |
| 29 // Skip past program name (first token in command line). | |
| 30 | |
| 31 if (*lpszCommandLine == '"') // Check for and handle quoted program name | |
| 32 { | |
| 33 lpszCommandLine++; // Get past the first quote | |
| 34 | |
| 35 // Now, scan, and skip over, subsequent characters until another | |
| 36 // double-quote or a null is encountered | |
| 37 while (*lpszCommandLine && (*lpszCommandLine != '"')) | |
| 38 lpszCommandLine++; | |
| 39 | |
| 40 // If we stopped on a double-quote (usual case), skip over it. | |
| 41 | |
| 42 if (*lpszCommandLine == '"') | |
| 43 lpszCommandLine++; | |
| 44 } | |
| 45 else // First token wasn't a quote | |
| 46 { | |
| 47 while (*lpszCommandLine > ' ') | |
| 48 lpszCommandLine++; | |
| 49 } | |
| 50 | |
| 51 // Skip past any white space preceeding the second token. | |
| 52 | |
| 53 while (*lpszCommandLine && (*lpszCommandLine <= ' ')) | |
| 54 lpszCommandLine++; | |
| 55 | |
| 56 StartupInfo.dwFlags = 0; | |
| 57 GetStartupInfo( &StartupInfo ); | |
| 58 | |
| 59 // set up our minimal cheezy atexit table | |
| 60 _atexit_init(); | |
| 61 | |
| 62 // Call C++ constructors | |
| 63 _initterm( __xc_a, __xc_z ); | |
| 64 | |
| 65 mainret = WinMain( GetModuleHandle(NULL), | |
| 66 NULL, | |
| 67 lpszCommandLine, | |
| 68 StartupInfo.dwFlags & STARTF_USESHOWWINDOW | |
| 69 ? StartupInfo.wShowWindow : SW_SHOWDEFAULT ); | |
| 70 | |
| 71 _DoExit(); | |
| 72 | |
| 73 ExitProcess(mainret); | |
| 74 } | |
| 75 | |
| OLD | NEW |