Release 960428
[wine/multimedia.git] / library / winmain.c
blobd1c0ac0dde40569a04a2e467dbe8981ebaf09334
1 #include <stdio.h>
2 #include <string.h>
3 #include <malloc.h>
4 #include "windows.h"
5 #include "wine.h"
6 #include "xmalloc.h"
8 extern int MAIN_Init(void);
9 extern BOOL WIDGETS_Init(void);
10 extern BOOL WIN_CreateDesktopWindow(void);
11 extern int PASCAL WinMain(HINSTANCE,HINSTANCE,LPSTR,int);
12 extern void TASK_Reschedule(void);
13 extern int USER_InitApp(HINSTANCE);
16 int _WinMain (int argc, char *argv [])
18 HINSTANCE hInstance;
19 LPSTR lpszCmdParam;
20 int i, len = 0;
22 /* Alloc szCmdParam */
23 for (i = 1; i < argc; i++) len += strlen(argv[i]) + 1;
24 lpszCmdParam = (LPSTR) xmalloc(len + 1);
25 /* Concatenate arguments */
26 if (argc > 1) strcpy(lpszCmdParam, argv[1]);
27 else lpszCmdParam[0] = '\0';
28 for (i = 2; i < argc; i++) strcat(strcat(lpszCmdParam, " "), argv[i]);
30 if(!MAIN_Init()) return 0; /* JBP: Needed for DosDrives[] structure, etc. */
31 hInstance = WinExec( *argv, SW_SHOWNORMAL );
32 TASK_Reschedule();
33 USER_InitApp( hInstance );
34 /* Perform global initialisations that need a task context */
35 if (!WIDGETS_Init()) return -1;
36 if (!WIN_CreateDesktopWindow()) return -1;
38 #ifdef WINELIBDLL
39 return (int)hInstance;
40 #else
41 return WinMain (hInstance, /* hInstance */
42 0, /* hPrevInstance */
43 lpszCmdParam, /* lpszCmdParam */
44 SW_NORMAL); /* nCmdShow */
45 #endif