blob: b35d94db4a14ded8a59c9536621eeedb947cdb81 [file] [log] [blame]
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001/*
2 * Emulator initialisation code
3 *
4 */
5
Alexandre Julliardc192ba22000-05-29 21:25:10 +00006#include "winbase.h"
Marcus Meissner317af321999-02-17 13:51:06 +00007#include "wine/winbase16.h"
Alexandre Julliardc192ba22000-05-29 21:25:10 +00008#include "wingdi.h"
9#include "winuser.h"
10
11#include "builtin32.h"
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000012#include "callback.h"
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000013#include "options.h"
Alexandre Julliarda845b881998-06-01 10:44:35 +000014#include "process.h"
Alexandre Julliard61fece01999-06-26 19:09:08 +000015#include "debugtools.h"
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000016
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000017/***********************************************************************
Ulrich Weigandc75d0e11998-11-01 17:59:35 +000018 * Main loop of initial task
19 */
Alexandre Julliardc192ba22000-05-29 21:25:10 +000020static void initial_task(void)
Ulrich Weigandc75d0e11998-11-01 17:59:35 +000021{
Alexandre Julliarda3960291999-02-26 11:11:13 +000022 MSG msg;
Alexandre Julliardc192ba22000-05-29 21:25:10 +000023 HINSTANCE16 instance;
24 STARTUPINFOA info;
Alexandre Julliard5b4f3e82000-05-01 16:24:22 +000025
Alexandre Julliardc192ba22000-05-29 21:25:10 +000026 GetStartupInfoA( &info );
27 if (!(info.dwFlags & STARTF_USESHOWWINDOW)) info.wShowWindow = SW_SHOWNORMAL;
28
29 if ((instance = WinExec16( GetCommandLineA(), info.wShowWindow )) < 32)
Alexandre Julliard5b4f3e82000-05-01 16:24:22 +000030 {
Alexandre Julliardc192ba22000-05-29 21:25:10 +000031 MESSAGE( "%s: can't exec '%s': ", argv0, GetCommandLineA() );
32 switch (instance)
Alexandre Julliardfe085682000-03-18 21:56:10 +000033 {
Alexandre Julliardc192ba22000-05-29 21:25:10 +000034 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 Weigande8b02741998-11-08 12:07:36 +000037 }
Alexandre Julliardc192ba22000-05-29 21:25:10 +000038 ExitProcess(instance);
Marcus Meissner40978651999-02-14 11:32:18 +000039 }
Ulrich Weigande8b02741998-11-08 12:07:36 +000040
Ulrich Weigande8b02741998-11-08 12:07:36 +000041 /* Start message loop for desktop window */
42
Ulrich Weiganda1957c41999-05-24 08:10:46 +000043 while ( GetNumTasks16() > 1 && Callout.GetMessageA( &msg, 0, 0, 0 ) )
Ulrich Weigandc75d0e11998-11-01 17:59:35 +000044 {
Alexandre Julliarda3960291999-02-26 11:11:13 +000045 Callout.TranslateMessage( &msg );
46 Callout.DispatchMessageA( &msg );
Ulrich Weiganda1957c41999-05-24 08:10:46 +000047 }
Ulrich Weigandc75d0e11998-11-01 17:59:35 +000048
49 ExitProcess( 0 );
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000050}
51
52
53/**********************************************************************
54 * main
55 */
56int main( int argc, char *argv[] )
57{
Alexandre Julliardc192ba22000-05-29 21:25:10 +000058 BUILTIN32_DESCRIPTOR descriptor;
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000059
Alexandre Julliardc192ba22000-05-29 21:25:10 +000060 memset( &descriptor, 0, sizeof(descriptor) );
61 descriptor.filename = argv[0];
62 descriptor.dllentrypoint = initial_task;
63 BUILTIN32_RegisterDLL( &descriptor );
Ulrich Weigande8b02741998-11-08 12:07:36 +000064
Alexandre Julliardc192ba22000-05-29 21:25:10 +000065 PROCESS_InitWine( argc, argv );
66 return 1; /* not reached */
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +000067}