Release 960314
[wine.git] / programs / progman / winexec.c
blob722576cc246485446859a3470a8c37b0311729c9
1 #ifdef WINELIB
2 #include <unistd.h>
3 #include <string.h>
4 #include "windows.h"
5 #include "winbase.h"
6 #include "options.h"
7 #include "dos_fs.h"
8 #include "debug.h"
9 #include "progman.h"
11 #define MAX_CMDLINE_SIZE 256
13 /* FIXME should use WinExec from -lwine */
15 HANDLE ProgmanWinExec( LPSTR lpCmdLine, WORD nCmdShow )
17 char wine[MAX_CMDLINE_SIZE];
18 char filename[MAX_CMDLINE_SIZE], *p;
19 char cmdline[MAX_CMDLINE_SIZE];
20 const char *argv[10], **argptr;
21 const char *unixfilename;
22 int simplename = 1;
24 if (fork()) return(INVALID_HANDLE_VALUE);
26 strncpy( filename, lpCmdLine, MAX_CMDLINE_SIZE );
27 filename[MAX_CMDLINE_SIZE-1] = '\0';
28 for (p = filename; *p && (*p != ' ') && (*p != '\t'); p++)
29 if ((*p == ':') || (*p == ':') || (*p == '/')) simplename = 0;
30 if (*p)
32 strncpy( cmdline, p + 1, 128 );
33 cmdline[127] = '\0';
35 else cmdline[0] = '\0';
36 *p = '\0';
38 if (simplename) unixfilename = filename;
39 else unixfilename = DOSFS_GetUnixFileName(filename, 0);
41 argptr = argv;
42 *argptr++ = unixfilename;
43 if (nCmdShow == SW_SHOWMINIMIZED) *argptr++ = "-iconic";
44 if (cmdline[0]) *argptr++ = cmdline;
45 *argptr++ = 0;
46 execvp(argv[0], (char**)argv);
48 PROFILE_GetWineIniString("progman", "wine", "wine",
49 wine, sizeof(wine));
50 argptr = argv;
51 *argptr++ = wine;
52 *argptr++ = "-language";
53 *argptr++ = Globals.lpszLanguage;
54 if (nCmdShow == SW_SHOWMINIMIZED) *argptr++ = "-iconic";
55 *argptr++ = lpCmdLine;
56 *argptr++ = 0;
57 execvp(argv[0] , (char**)argv);
59 printf("Cannot exec `%s %s %s%s %s'\n",
60 wine, "-language", Globals.lpszLanguage,
61 nCmdShow == SW_SHOWMINIMIZED ? " -iconic" : "",
62 lpCmdLine);
63 exit(1);
66 BOOL ProgmanWinHelp(HWND hWnd, LPSTR lpHelpFile, WORD wCommand, DWORD dwData)
68 char str[256];
69 dprintf_exec(stddeb,"WinHelp(%s, %u, %lu)\n",
70 lpHelpFile, wCommand, dwData);
71 switch(wCommand) {
72 case 0:
73 case HELP_HELPONHELP:
74 GetWindowsDirectory(str, sizeof(str));
75 strcat(str, "\\winhelp.exe winhelp.hlp");
76 dprintf_exec(stddeb,"'%s'\n", str);
77 break;
78 case HELP_INDEX:
79 GetWindowsDirectory(str, sizeof(str));
80 strcat(str, "\\winhelp.exe ");
81 strcat(str, lpHelpFile);
82 dprintf_exec(stddeb,"'%s'\n", str);
83 break;
84 default:
85 return FALSE;
87 WinExec(str, SW_SHOWNORMAL);
88 return(TRUE);
91 #endif