Release 960428
[wine/multimedia.git] / loader / main.c
blob334ec826b1a91eebcf1450505e8dc6fbd5389611
1 /*
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";
4 */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <sys/types.h>
8 #include <sys/stat.h>
9 #include <fcntl.h>
10 #include <unistd.h>
11 #include <string.h>
12 #include <errno.h>
13 #include "windows.h"
14 #include "alias.h"
15 #include "module.h"
16 #include "task.h"
17 #include "selectors.h"
18 #include "comm.h"
19 #include "win.h"
20 #include "menu.h"
21 #include "kernel32.h"
22 #include "atom.h"
23 #include "dialog.h"
24 #include "directory.h"
25 #include "drive.h"
26 #include "queue.h"
27 #include "syscolor.h"
28 #include "sysmetrics.h"
29 #include "gdi.h"
30 #include "heap.h"
31 #include "debugger.h"
32 #include "miscemu.h"
33 #include "neexe.h"
34 #include "options.h"
35 #include "spy.h"
36 #include "task.h"
37 #include "dce.h"
38 #include "pe_image.h"
39 #include "stddebug.h"
40 #include "debug.h"
42 void init_wine_signals(void);
44 HANDLE32 SystemHeap = 0;
46 /***********************************************************************
47 * Main initialisation routine
49 int MAIN_Init(void)
51 extern BOOL RELAY_Init(void);
53 int queueSize;
55 /* Create the system heap */
56 if (!(SystemHeap = HeapCreate( HEAP_GROWABLE, 0x10000, 0 ))) return 0;
58 /* Load the configuration file */
59 if (!PROFILE_LoadWineIni()) return 0;
61 /* Initialize message spying */
62 if (!SPY_Init()) return 0;
64 #ifndef WINELIB
65 /* Initialize relay code */
66 if (!RELAY_Init()) return 0;
68 /* Create built-in modules */
69 if (!BUILTIN_Init()) return 0;
70 #endif
72 /* Initialise DOS drives */
73 if (!DRIVE_Init()) return 0;
75 /* Initialise DOS directories */
76 if (!DIR_Init()) return 0;
78 /* Initialize tasks */
79 if (!TASK_Init()) return 0;
81 /* Initialize communications */
82 COMM_Init();
84 #ifndef WINELIB
85 /* Initialize interrupt vectors */
86 if (!INT_Init()) return 0;
88 /* Initialize DOS memory */
89 if (!DOSMEM_Init()) return 0;
91 /* Initialize signal handling */
92 init_wine_signals();
94 /* Initialize the DOS memory */
95 if (!INT21_Init()) return 0;
96 #endif
98 /* Global atom table initialisation */
99 if (!ATOM_Init()) return 0;
101 /* GDI initialisation */
102 if (!GDI_Init()) return 0;
104 /* Initialise window procedures aliases */
105 if (!ALIAS_Init()) return 0;
107 /* Initialize system colors and metrics*/
108 SYSMETRICS_Init();
109 SYSCOLOR_Init();
111 /* Create the DCEs */
112 DCE_Init();
114 /* Initialize dialog manager */
115 if (!DIALOG_Init()) return 0;
117 /* Initialize menus */
118 if (!MENU_Init()) return 0;
120 /* Initialize Win32 data structures */
121 if (!KERN32_Init()) return 0;
123 /* Create system message queue */
124 queueSize = GetProfileInt( "windows", "TypeAhead", 120 );
125 if (!QUEUE_CreateSysMsgQueue( queueSize )) return 0;
127 /* Set double click time */
128 SetDoubleClickTime( GetProfileInt( "windows", "DoubleClickSpeed", 452 ) );
130 return 1;
134 #ifndef WINELIB
135 /**********************************************************************
136 * main
138 int _WinMain(int argc, char **argv)
140 int i;
141 HANDLE handle;
143 if (!MAIN_Init()) return 0;
145 for (i = 1; i < argc; i++)
147 if ((handle = WinExec( argv[i], SW_SHOWNORMAL )) < 32)
149 fprintf(stderr, "wine: can't exec '%s': ", argv[i]);
150 switch (handle)
152 case 2: fprintf( stderr, "file not found\n" ); break;
153 case 11: fprintf( stderr, "invalid exe file\n" ); break;
154 case 21: fprintf( stderr, "win32 executable\n" ); break;
155 default: fprintf( stderr, "error=%d\n", handle ); break;
157 exit(1);
161 if (Options.debug) DEBUG_SetBreakpoints( TRUE ); /* Setup breakpoints */
163 Yield(); /* Start the first task */
164 fprintf( stderr, "WinMain: Should never happen: returned from Yield()\n" );
165 return 0;
168 #endif /* #ifndef WINELIB */