wine/miscemu/main.c
Alexandre Julliard 105b0f4e64 Use the exe name and file handle we got from the server also when
starting Win16 or DOS programs, to avoid depending on the contents of
the command-line.
2001-01-06 01:55:49 +00:00

80 lines
2.1 KiB
C

/*
* Emulator initialisation code
*
*/
#include "winbase.h"
#include "wine/winbase16.h"
#include "wingdi.h"
#include "winuser.h"
#include "miscemu.h"
#include "callback.h"
#include "options.h"
#include "dosexe.h"
#include "debugtools.h"
static char main_exe_name[MAX_PATH];
static HANDLE main_exe_file;
extern void PROCESS_InitWine( int argc, char *argv[], LPSTR win16_exe_name,
HANDLE *win16_exe_file ) WINE_NORETURN;
extern HINSTANCE16 NE_StartMain( LPCSTR name, HANDLE file );
/***********************************************************************
* Main loop of initial task
*/
int WINAPI wine_initial_task( HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, INT show )
{
MSG msg;
HINSTANCE16 instance;
if (!LoadLibraryA( "user32.dll" ))
{
MESSAGE( "Cannot load user32.dll\n" );
ExitProcess( GetLastError() );
}
THUNK_InitCallout();
if ((instance = NE_StartMain( main_exe_name, main_exe_file )) < 32)
{
if (instance == 11) /* try DOS format */
{
if (DPMI_LoadDosSystem())
Dosvm.LoadDosExe( main_exe_name, main_exe_file );
/* if we get back here it failed */
instance = GetLastError();
}
MESSAGE( "%s: can't exec '%s': ", argv0, GetCommandLineA() );
switch (instance)
{
case 2: MESSAGE("file not found\n" ); break;
case 11: MESSAGE("invalid exe file\n" ); break;
default: MESSAGE("error=%d\n", instance ); break;
}
ExitProcess(instance);
}
CloseHandle( main_exe_file ); /* avoid file sharing problems */
/* Start message loop for desktop window */
while ( GetNumTasks16() > 1 && Callout.GetMessageA( &msg, 0, 0, 0 ) )
{
Callout.TranslateMessage( &msg );
Callout.DispatchMessageA( &msg );
}
ExitProcess( 0 );
}
/**********************************************************************
* main
*/
int main( int argc, char *argv[] )
{
PROCESS_InitWine( argc, argv, main_exe_name, &main_exe_file );
return 1; /* not reached */
}