Release 940301
[wine/gsoc-2012-control.git] / misc / exec.c
bloba41a95cdc90cc0764777e882339a424342081e83
1 /*
2 * Windows Exec & Help
4 */
6 #include "windows.h"
8 #define HELP_CONTEXT 0x0001
9 #define HELP_QUIT 0x0002
10 #define HELP_INDEX 0x0003
11 #define HELP_CONTENTS 0x0003
12 #define HELP_HELPONHELP 0x0004
13 #define HELP_SETINDEX 0x0005
14 #define HELP_SETCONTENTS 0x0005
15 #define HELP_CONTEXTPOPUP 0x0008
16 #define HELP_FORCEFILE 0x0009
17 #define HELP_KEY 0x0101
18 #define HELP_COMMAND 0x0102
19 #define HELP_PARTIALKEY 0x0105
20 #define HELP_MULTIKEY 0x0201
21 #define HELP_SETWINPOS 0x0203
24 WORD WinExec(LPSTR lpCmdLine, WORD nCmdShow)
26 int X, X2, C;
27 char *ArgV[20];
28 printf("WinExec('%s', %04X)\n", lpCmdLine, nCmdShow);
29 for (X = X2 = C = 0; X < strlen(lpCmdLine) + 1; X++) {
30 if ((lpCmdLine[X] == ' ') || (lpCmdLine[X] == '\0')) {
31 ArgV[C] = (char *)malloc(X - X2 + 1);
32 strncpy(ArgV[C], &lpCmdLine[X2], X - X2);
33 ArgV[C][X - X2] = '\0';
34 C++; X2 = X + 1;
37 ArgV[C] = NULL;
38 for (C = 0; ; C++) {
39 if (ArgV[C] == NULL) break;
40 printf("--> '%s' \n", ArgV[C]);
42 switch(fork()) {
43 case -1:
44 printf("Can't 'fork' process !\n");
45 break;
46 case 0:
47 printf("New process started !\n");
48 execvp(ArgV[0], ArgV);
49 printf("Child process died !\n");
50 exit(1);
51 break;
52 default:
53 printf("Main process stay alive !\n");
54 break;
56 for (C = 0; ; C++) {
57 if (ArgV[C] == NULL) break;
58 free(ArgV[C]);
60 return(TRUE);
64 BOOL WinHelp(HWND hWnd, LPSTR lpHelpFile, WORD wCommand, DWORD dwData)
66 char *ArgV[6];
67 char str[32];
68 printf("WinHelp(%s, %u, %lu)\n", lpHelpFile, wCommand, dwData);
69 switch(fork()) {
70 case -1:
71 printf("Can't 'fork' process !\n");
72 break;
73 case 0:
74 printf("New process started !\n");
75 ArgV[0] = "wine";
76 ArgV[1] = "winhelp.exe";
77 ArgV[2] = lpHelpFile;
78 switch (wCommand) {
79 case HELP_CONTEXT:
80 case HELP_KEY:
81 case HELP_SETINDEX:
82 sprintf(str, "%lu", dwData);
83 ArgV[3] = str;
84 default:
85 ArgV[3] = NULL;
87 ArgV[4] = NULL;
88 if (wCommand == HELP_HELPONHELP) ArgV[2] = NULL;
90 _WinMain(ArgV, 2);
92 execvp(ArgV[0], ArgV);
93 printf("Child process died !\n");
94 exit(1);
95 break;
96 default:
97 printf("Main process stay alive !\n");
98 break;
100 return(TRUE);