Release 940405
[wine/gsoc-2012-control.git] / misc / exec.c
blobf6730c610d9667a076fab461b948df526625d39e
1 /*
2 * Windows Exec & Help
4 */
6 #include <stdlib.h>
7 #include <stdio.h>
8 #include <string.h>
9 #include <unistd.h>
10 #include "windows.h"
12 #define HELP_CONTEXT 0x0001
13 #define HELP_QUIT 0x0002
14 #define HELP_INDEX 0x0003
15 #define HELP_CONTENTS 0x0003
16 #define HELP_HELPONHELP 0x0004
17 #define HELP_SETINDEX 0x0005
18 #define HELP_SETCONTENTS 0x0005
19 #define HELP_CONTEXTPOPUP 0x0008
20 #define HELP_FORCEFILE 0x0009
21 #define HELP_KEY 0x0101
22 #define HELP_COMMAND 0x0102
23 #define HELP_PARTIALKEY 0x0105
24 #define HELP_MULTIKEY 0x0201
25 #define HELP_SETWINPOS 0x0203
28 WORD WinExec(LPSTR lpCmdLine, WORD nCmdShow)
30 int X, X2, C;
31 char *ArgV[20];
32 printf("WinExec('%s', %04X)\n", lpCmdLine, nCmdShow);
33 ArgV[0] = "wine";
34 C = 1;
35 for (X = X2 = 0; X < strlen(lpCmdLine) + 1; X++) {
36 if ((lpCmdLine[X] == ' ') || (lpCmdLine[X] == '\0')) {
37 ArgV[C] = (char *)malloc(X - X2 + 1);
38 strncpy(ArgV[C], &lpCmdLine[X2], X - X2);
39 ArgV[C][X - X2] = '\0';
40 C++; X2 = X + 1;
43 ArgV[C] = NULL;
44 for (C = 0; ; C++) {
45 if (ArgV[C] == NULL) break;
46 printf("--> '%s' \n", ArgV[C]);
48 switch(fork()) {
49 case -1:
50 printf("Can't 'fork' process !\n");
51 break;
52 case 0:
53 printf("New process started !\n");
54 execvp(ArgV[0], ArgV);
55 printf("Child process died !\n");
56 exit(1);
57 break;
58 default:
59 printf("Main process stay alive !\n");
60 break;
62 for (C = 0; ; C++) {
63 if (ArgV[C] == NULL) break;
64 free(ArgV[C]);
66 return(TRUE);
70 BOOL WinHelp(HWND hWnd, LPSTR lpHelpFile, WORD wCommand, DWORD dwData)
72 char str[256];
73 printf("WinHelp(%s, %u, %lu)\n", lpHelpFile, wCommand, dwData);
74 switch(wCommand) {
75 case 0:
76 case HELP_HELPONHELP:
77 GetWindowsDirectory(str, sizeof(str));
78 strcat(str, "\\winhelp.exe");
79 printf("'%s'\n", str);
80 break;
81 case HELP_INDEX:
82 GetWindowsDirectory(str, sizeof(str));
83 strcat(str, "\\winhelp.exe");
84 printf("'%s'\n", str);
85 break;
86 default:
87 return FALSE;
89 WinExec(str, SW_SHOWNORMAL);
90 return(TRUE);