2 * Emulator initialisation code
7 #include "wine/winbase16.h"
15 #include "debugtools.h"
17 static char main_exe_name
[MAX_PATH
];
18 static HANDLE main_exe_file
;
20 static BOOL (WINAPI
*pGetMessageA
)(LPMSG
,HWND
,UINT
,UINT
);
21 static BOOL (WINAPI
*pTranslateMessage
)(const MSG
*);
22 static LONG (WINAPI
*pDispatchMessageA
)(const MSG
*);
24 extern void PROCESS_InitWine( int argc
, char *argv
[], LPSTR win16_exe_name
,
25 HANDLE
*win16_exe_file
) WINE_NORETURN
;
26 extern HINSTANCE16
NE_StartMain( LPCSTR name
, HANDLE file
);
28 /***********************************************************************
29 * Main loop of initial task
31 int WINAPI
wine_initial_task( HINSTANCE inst
, HINSTANCE prev
, LPSTR cmdline
, INT show
)
37 if (!(user32
= LoadLibraryA( "user32.dll" )))
39 MESSAGE( "Cannot load user32.dll\n" );
40 ExitProcess( GetLastError() );
42 pGetMessageA
= (void *)GetProcAddress( user32
, "GetMessageA" );
43 pTranslateMessage
= (void *)GetProcAddress( user32
, "TranslateMessage" );
44 pDispatchMessageA
= (void *)GetProcAddress( user32
, "DispatchMessageA" );
47 if ((instance
= NE_StartMain( main_exe_name
, main_exe_file
)) < 32)
49 if (instance
== 11) /* try DOS format */
51 if (DPMI_LoadDosSystem())
52 Dosvm
.LoadDosExe( main_exe_name
, main_exe_file
);
53 /* if we get back here it failed */
54 instance
= GetLastError();
57 MESSAGE( "%s: can't exec '%s': ", argv0
, GetCommandLineA() );
60 case 2: MESSAGE("file not found\n" ); break;
61 case 11: MESSAGE("invalid exe file\n" ); break;
62 default: MESSAGE("error=%d\n", instance
); break;
64 ExitProcess(instance
);
66 CloseHandle( main_exe_file
); /* avoid file sharing problems */
68 /* Start message loop for desktop window */
70 while ( GetNumTasks16() > 1 && pGetMessageA( &msg
, 0, 0, 0 ) )
72 pTranslateMessage( &msg
);
73 pDispatchMessageA( &msg
);
80 /**********************************************************************
83 int main( int argc
, char *argv
[] )
85 PROCESS_InitWine( argc
, argv
, main_exe_name
, &main_exe_file
);
86 return 1; /* not reached */