Release 980517
[wine/multimedia.git] / loader / main.c
blob5b1eaec76cf41dc0ab739beee21d796314b060cf
1 /*
2 * Main initialization code
3 */
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 "bitmap.h"
15 #include "comm.h"
16 #include "win.h"
17 #include "main.h"
18 #include "menu.h"
19 #include "atom.h"
20 #include "dialog.h"
21 #include "drive.h"
22 #include "queue.h"
23 #include "sysmetrics.h"
24 #include "file.h"
25 #include "gdi.h"
26 #include "heap.h"
27 #include "keyboard.h"
28 #include "miscemu.h"
29 #include "options.h"
30 #include "spy.h"
31 #include "tweak.h"
32 #include "user.h"
33 #include "dce.h"
34 #include "shell.h"
35 #include "winproc.h"
36 #include "debug.h"
39 int __winelib = 1; /* Winelib run-time flag */
41 /***********************************************************************
42 * Kernel initialisation routine
44 BOOL32 MAIN_KernelInit(void)
46 extern BOOL32 EVENT_Init(void);
48 /* Initialize signal handling */
49 if (!SIGNAL_Init()) return FALSE;
51 /* Load the configuration file */
52 if (!PROFILE_LoadWineIni()) return FALSE;
54 /* Initialize DOS memory */
55 if (!DOSMEM_Init()) return FALSE;
57 /* Initialise DOS drives */
58 if (!DRIVE_Init()) return FALSE;
60 /* Initialise DOS directories */
61 if (!DIR_Init()) return FALSE;
63 /* Initialize event handling */
64 if (!EVENT_Init()) return FALSE;
66 /* Initialize communications */
67 COMM_Init();
69 /* Initialize IO-port permissions */
70 IO_port_init();
72 return TRUE;
76 /***********************************************************************
77 * USER (and GDI) initialisation routine
79 BOOL32 MAIN_UserInit(void)
81 extern BOOL32 WIDGETS_Init(void);
82 extern BOOL32 MULTIMEDIA_Init(void);
84 int queueSize;
86 /* Create USER and GDI heap */
87 if (!USER_HeapSel)
89 USER_HeapSel = GlobalAlloc16( GMEM_FIXED, 0x10000 );
90 LocalInit( USER_HeapSel, 0, 0xffff );
92 if (!GDI_HeapSel)
94 GDI_HeapSel = GlobalAlloc16( GMEM_FIXED, GDI_HEAP_SIZE );
95 LocalInit( GDI_HeapSel, 0, GDI_HEAP_SIZE-1 );
98 /* Initialize Wine tweaks */
99 if (!TWEAK_Init()) return FALSE;
101 /* Initialize OEM Bitmaps */
102 if (!OBM_Init()) return FALSE;
104 /* registry initialisation */
105 SHELL_LoadRegistry();
107 /* Global atom table initialisation */
108 if (!ATOM_Init()) return FALSE;
110 /* GDI initialisation */
111 if (!GDI_Init()) return FALSE;
113 /* Initialize system colors and metrics*/
114 SYSMETRICS_Init();
115 SYSCOLOR_Init();
117 /* Create the DCEs */
118 DCE_Init();
120 /* Initialize keyboard */
121 if (!KEYBOARD_Init()) return FALSE;
123 /* Initialize window procedures */
124 if (!WINPROC_Init()) return FALSE;
126 /* Initialize built-in window classes */
127 if (!WIDGETS_Init()) return FALSE;
129 /* Initialize dialog manager */
130 if (!DIALOG_Init()) return FALSE;
132 /* Initialize menus */
133 if (!MENU_Init()) return FALSE;
135 /* Initialize multimedia */
136 if (!MULTIMEDIA_Init()) return FALSE;
138 /* Create desktop window */
139 if (!WIN_CreateDesktopWindow()) return FALSE;
141 /* Initialize message spying */
142 if (!SPY_Init()) return FALSE;
144 /* Check wine.conf for old/bad entries */
145 if (!TWEAK_CheckConfiguration()) return FALSE;
147 /* Create system message queue */
148 queueSize = GetProfileInt32A( "windows", "TypeAhead", 120 );
149 if (!QUEUE_CreateSysMsgQueue( queueSize )) return FALSE;
151 /* Set double click time */
152 SetDoubleClickTime32( GetProfileInt32A("windows","DoubleClickSpeed",452) );
154 return TRUE;
158 /***********************************************************************
159 * Winelib initialisation routine
161 BOOL32 MAIN_WinelibInit( int *argc, char *argv[] )
163 extern BOOL32 PROCESS_Init(void);
165 /* Create the initial process */
166 if (!PROCESS_Init()) return FALSE;
168 /* Parse command line arguments */
169 MAIN_WineInit( argc, argv );
171 /* Initialize the kernel */
172 if (!MAIN_KernelInit()) return FALSE;
174 /* Initialize all the USER stuff */
175 if (!MAIN_UserInit()) return FALSE;
177 return TRUE;