2 static char RCSId[] = "$Id: wine.c,v 1.2 1993/07/04 04:04:21 root Exp root $";
3 static char Copyright[] = "Copyright Robert J. Amstadt, 1993";
15 #include "selectors.h"
25 #include "sysmetrics.h"
47 int __winelib
= 1; /* Winelib run-time flag */
49 HANDLE32 SystemHeap
= 0;
50 HANDLE32 SegptrHeap
= 0;
52 /***********************************************************************
53 * Main initialisation routine
57 extern BOOL32
RELAY_Init(void);
58 extern BOOL32
WIN16DRV_Init(void);
59 extern BOOL32
VIRTUAL_Init(void);
60 extern BOOL32
WIDGETS_Init(void);
64 /* Initialize virtual memory management */
65 if (!VIRTUAL_Init()) return 0;
67 /* Create the system and SEGPTR heaps */
68 if (!(SystemHeap
= HeapCreate( HEAP_GROWABLE
, 0x10000, 0 ))) return 0;
69 if (!(SegptrHeap
= HeapCreate( HEAP_WINE_SEGPTR
, 0, 0 ))) return 0;
71 /* Load the configuration file */
72 if (!PROFILE_LoadWineIni()) return 0;
74 /* Initialize DOS memory */
75 if (!DOSMEM_Init()) return 0;
77 /* Initialize signal handling */
78 if (!SIGNAL_Init()) return 0;
81 /* Create USER and GDI heap */
82 USER_HeapSel
= GlobalAlloc16( GMEM_FIXED
, 0x10000 );
83 LocalInit( USER_HeapSel
, 0, 0xffff );
84 GDI_HeapSel
= GlobalAlloc16( GMEM_FIXED
, GDI_HEAP_SIZE
);
85 LocalInit( GDI_HeapSel
, 0, GDI_HEAP_SIZE
-1 );
87 /* Initialize relay code */
88 if (!RELAY_Init()) return 0;
90 /* Create built-in modules */
91 if (!BUILTIN_Init()) return 0;
93 /* Initialize signal handling */
94 if (!SIGNAL_InitEmulator()) return 0;
96 /* Create the Win16 printer driver */
97 if (!WIN16DRV_Init()) return 0;
100 /* Initialize Wine tweaks */
101 if (!TWEAK_Init()) return 0;
103 /* Initialize OEM Bitmaps */
104 if (!OBM_Init()) return 0;
106 /* Initialise DOS drives */
107 if (!DRIVE_Init()) return 0;
109 /* Initialise DOS directories */
110 if (!DIR_Init()) return 0;
112 /* Initialize tasks */
113 if (!TASK_Init()) return 0;
115 /* Initialize communications */
118 /* Initialize IO-port permissions */
121 /* registry initialisation */
122 SHELL_LoadRegistry();
124 /* Global atom table initialisation */
125 if (!ATOM_Init()) return 0;
127 /* GDI initialisation */
128 if (!GDI_Init()) return 0;
130 /* Initialize system colors and metrics*/
134 /* Create the DCEs */
137 /* Initialize keyboard */
138 if (!KEYBOARD_Init()) return 0;
140 /* Initialize window procedures */
141 if (!WINPROC_Init()) return 0;
143 /* Initialize built-in window classes */
144 if (!WIDGETS_Init()) return 0;
146 /* Initialize dialog manager */
147 if (!DIALOG_Init()) return 0;
149 /* Initialize menus */
150 if (!MENU_Init()) return 0;
152 /* Create desktop window */
153 if (!WIN_CreateDesktopWindow()) return 0;
155 /* Initialize message spying */
156 if (!SPY_Init()) return 0;
158 /* Check wine.conf for old/bad entries */
159 if (!TWEAK_CheckConfiguration()) return 0;
161 /* Create system message queue */
162 queueSize
= GetProfileInt32A( "windows", "TypeAhead", 120 );
163 if (!QUEUE_CreateSysMsgQueue( queueSize
)) return 0;
165 /* Set double click time */
166 SetDoubleClickTime32( GetProfileInt32A("windows","DoubleClickSpeed",452) );
173 /**********************************************************************
176 int main(int argc
, char *argv
[] )
178 extern BOOL32
MAIN_WineInit( int *argc
, char *argv
[] );
179 extern char * DEBUG_argv0
;
184 __winelib
= 0; /* First of all, clear the Winelib flag */
187 * Save this so that the internal debugger can get a hold of it if
190 DEBUG_argv0
= argv
[0];
192 if (!MAIN_WineInit( &argc
, argv
)) return 1;
193 if (!MAIN_Init()) return 1;
196 for (i
= 1; i
< argc
; i
++)
198 if ((handle
= WinExec32( argv
[i
], SW_SHOWNORMAL
)) < 32)
200 fprintf(stderr
, "wine: can't exec '%s': ", argv
[i
]);
203 case 2: fprintf( stderr
, "file not found\n" ); break;
204 case 11: fprintf( stderr
, "invalid exe file\n" ); break;
205 case 21: fprintf( stderr
, "win32 executable\n" ); break;
206 default: fprintf( stderr
, "error=%d\n", handle
); break;
213 if (!loaded
) { /* nothing loaded */
214 extern void MAIN_Usage(char*);
221 fprintf( stderr
, "wine: no executable file found.\n" );
225 if (Options
.debug
) DEBUG_SetBreakpoints( TRUE
); /* Setup breakpoints */
227 Yield(); /* Start the first task */
228 fprintf( stderr
, "WinMain: Should never happen: returned from Yield()\n" );
232 #endif /* #ifndef WINELIB */