Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Emulator initialisation code |
| 3 | * |
| 4 | */ |
| 5 | |
Alexandre Julliard | c192ba2 | 2000-05-29 21:25:10 +0000 | [diff] [blame] | 6 | #include "winbase.h" |
Marcus Meissner | 317af32 | 1999-02-17 13:51:06 +0000 | [diff] [blame] | 7 | #include "wine/winbase16.h" |
Alexandre Julliard | c192ba2 | 2000-05-29 21:25:10 +0000 | [diff] [blame] | 8 | #include "wingdi.h" |
| 9 | #include "winuser.h" |
| 10 | |
| 11 | #include "builtin32.h" |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 12 | #include "callback.h" |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 13 | #include "options.h" |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 14 | #include "process.h" |
Alexandre Julliard | 61fece0 | 1999-06-26 19:09:08 +0000 | [diff] [blame] | 15 | #include "debugtools.h" |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 16 | |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 17 | /*********************************************************************** |
Ulrich Weigand | c75d0e1 | 1998-11-01 17:59:35 +0000 | [diff] [blame] | 18 | * Main loop of initial task |
| 19 | */ |
Alexandre Julliard | c192ba2 | 2000-05-29 21:25:10 +0000 | [diff] [blame] | 20 | static void initial_task(void) |
Ulrich Weigand | c75d0e1 | 1998-11-01 17:59:35 +0000 | [diff] [blame] | 21 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 22 | MSG msg; |
Alexandre Julliard | c192ba2 | 2000-05-29 21:25:10 +0000 | [diff] [blame] | 23 | HINSTANCE16 instance; |
| 24 | STARTUPINFOA info; |
Alexandre Julliard | 5b4f3e8 | 2000-05-01 16:24:22 +0000 | [diff] [blame] | 25 | |
Alexandre Julliard | c192ba2 | 2000-05-29 21:25:10 +0000 | [diff] [blame] | 26 | GetStartupInfoA( &info ); |
| 27 | if (!(info.dwFlags & STARTF_USESHOWWINDOW)) info.wShowWindow = SW_SHOWNORMAL; |
| 28 | |
| 29 | if ((instance = WinExec16( GetCommandLineA(), info.wShowWindow )) < 32) |
Alexandre Julliard | 5b4f3e8 | 2000-05-01 16:24:22 +0000 | [diff] [blame] | 30 | { |
Alexandre Julliard | c192ba2 | 2000-05-29 21:25:10 +0000 | [diff] [blame] | 31 | MESSAGE( "%s: can't exec '%s': ", argv0, GetCommandLineA() ); |
| 32 | switch (instance) |
Alexandre Julliard | fe08568 | 2000-03-18 21:56:10 +0000 | [diff] [blame] | 33 | { |
Alexandre Julliard | c192ba2 | 2000-05-29 21:25:10 +0000 | [diff] [blame] | 34 | case 2: MESSAGE("file not found\n" ); break; |
| 35 | case 11: MESSAGE("invalid exe file\n" ); break; |
| 36 | default: MESSAGE("error=%d\n", instance ); break; |
Ulrich Weigand | e8b0274 | 1998-11-08 12:07:36 +0000 | [diff] [blame] | 37 | } |
Alexandre Julliard | c192ba2 | 2000-05-29 21:25:10 +0000 | [diff] [blame] | 38 | ExitProcess(instance); |
Marcus Meissner | 4097865 | 1999-02-14 11:32:18 +0000 | [diff] [blame] | 39 | } |
Ulrich Weigand | e8b0274 | 1998-11-08 12:07:36 +0000 | [diff] [blame] | 40 | |
Ulrich Weigand | e8b0274 | 1998-11-08 12:07:36 +0000 | [diff] [blame] | 41 | /* Start message loop for desktop window */ |
| 42 | |
Ulrich Weigand | a1957c4 | 1999-05-24 08:10:46 +0000 | [diff] [blame] | 43 | while ( GetNumTasks16() > 1 && Callout.GetMessageA( &msg, 0, 0, 0 ) ) |
Ulrich Weigand | c75d0e1 | 1998-11-01 17:59:35 +0000 | [diff] [blame] | 44 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 45 | Callout.TranslateMessage( &msg ); |
| 46 | Callout.DispatchMessageA( &msg ); |
Ulrich Weigand | a1957c4 | 1999-05-24 08:10:46 +0000 | [diff] [blame] | 47 | } |
Ulrich Weigand | c75d0e1 | 1998-11-01 17:59:35 +0000 | [diff] [blame] | 48 | |
| 49 | ExitProcess( 0 ); |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | |
| 53 | /********************************************************************** |
| 54 | * main |
| 55 | */ |
| 56 | int main( int argc, char *argv[] ) |
| 57 | { |
Alexandre Julliard | c192ba2 | 2000-05-29 21:25:10 +0000 | [diff] [blame] | 58 | BUILTIN32_DESCRIPTOR descriptor; |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 59 | |
Alexandre Julliard | c192ba2 | 2000-05-29 21:25:10 +0000 | [diff] [blame] | 60 | memset( &descriptor, 0, sizeof(descriptor) ); |
| 61 | descriptor.filename = argv[0]; |
| 62 | descriptor.dllentrypoint = initial_task; |
| 63 | BUILTIN32_RegisterDLL( &descriptor ); |
Ulrich Weigand | e8b0274 | 1998-11-08 12:07:36 +0000 | [diff] [blame] | 64 | |
Alexandre Julliard | c192ba2 | 2000-05-29 21:25:10 +0000 | [diff] [blame] | 65 | PROCESS_InitWine( argc, argv ); |
| 66 | return 1; /* not reached */ |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 67 | } |