lpszName of NULL is handled (removes some warnings).
[wine/multimedia.git] / library / winestub.c
blobf81eda60addb16b3fddce7c69357675507685d35
1 /* Sample winestub.c file for compiling programs with libwine.so. */
3 #include <string.h>
4 #include "windows.h"
5 #include "xmalloc.h"
7 extern int PASCAL WinMain(HINSTANCE32,HINSTANCE32,LPSTR,int);
8 extern BOOL32 MAIN_WinelibInit( int *argc, char *argv[] );
9 extern void TASK_Reschedule(void);
11 /* Most Windows C/C++ compilers use something like this to */
12 /* access argc and argv globally: */
13 int _ARGC;
14 char **_ARGV;
16 int main( int argc, char *argv [] )
18 HINSTANCE32 hInstance;
19 LPSTR lpszCmdParam;
20 int i, len = 0;
21 _ARGC = argc;
22 _ARGV = (char **)argv;
24 if (!MAIN_WinelibInit( &argc, argv )) return 0;
26 /* Alloc szCmdParam */
27 for (i = 1; i < argc; i++) len += strlen(argv[i]) + 1;
28 lpszCmdParam = (LPSTR) xmalloc(len + 1);
29 /* Concatenate arguments */
30 if (argc > 1) strcpy(lpszCmdParam, argv[1]);
31 else lpszCmdParam[0] = '\0';
32 for (i = 2; i < argc; i++) strcat(strcat(lpszCmdParam, " "), argv[i]);
34 hInstance = WinExec32( *argv, SW_SHOWNORMAL );
35 TASK_Reschedule();
36 InitApp( hInstance );
38 return WinMain (hInstance, /* hInstance */
39 0, /* hPrevInstance */
40 lpszCmdParam, /* lpszCmdParam */
41 SW_NORMAL); /* nCmdShow */