replaced a DPRINTF by a TRACE
[wine.git] / library / winestub.c
blob40a2664ae6773d1be8cef49e65ac1767daf1bfe5
1 /* Sample winestub.c file for compiling programs with libwine.so. */
3 #include <string.h>
4 #include "windef.h"
5 #include "winbase.h"
6 #include "wingdi.h"
7 #include "winuser.h"
8 #include "debugtools.h"
10 extern int PASCAL WinMain(HINSTANCE,HINSTANCE,LPSTR,int);
12 /* external declaration here because we don't want to depend on Wine headers */
13 #ifdef __cplusplus
14 extern "C" HINSTANCE MAIN_WinelibInit( int *argc, char *argv[] );
15 #else
16 extern HINSTANCE MAIN_WinelibInit( int *argc, char *argv[] );
17 #endif
19 /* Most Windows C/C++ compilers use something like this to */
20 /* access argc and argv globally: */
21 int _ARGC;
22 char **_ARGV;
24 int main( int argc, char *argv [] )
26 HINSTANCE hInstance;
27 LPSTR lpszCmdParam;
28 int i, len = 0, retv;
29 _ARGC = argc;
30 _ARGV = (char **)argv;
32 if (!(hInstance = MAIN_WinelibInit( &argc, argv ))) return 0;
34 /* Alloc szCmdParam */
35 for (i = 1; i < argc; i++) len += strlen(argv[i]) + 1;
36 lpszCmdParam = (LPSTR) malloc(len + 1);
37 if(lpszCmdParam == NULL) {
38 MESSAGE("Not enough memory to store command parameters!");
39 return 1;
41 /* Concatenate arguments */
42 if (argc > 1) strcpy(lpszCmdParam, argv[1]);
43 else lpszCmdParam[0] = '\0';
44 for (i = 2; i < argc; i++) strcat(strcat(lpszCmdParam, " "), argv[i]);
46 retv = WinMain (hInstance, /* hInstance */
47 0, /* hPrevInstance */
48 lpszCmdParam, /* lpszCmdParam */
49 SW_NORMAL); /* nCmdShow */
51 ExitProcess( retv );
52 return retv;