[78] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: systemf.c 1438 2009-06-28 20:47:00Z gyoung $
|
---|
| 5 |
|
---|
| 6 | System Interfaces
|
---|
| 7 |
|
---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
---|
[1394] | 9 | Copyright (c) 2003, 2009 Steven H.Levine
|
---|
[78] | 10 |
|
---|
[330] | 11 | 21 Nov 03 SHL Comments
|
---|
| 12 | 31 Jul 04 SHL Indent -i2
|
---|
| 13 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
| 14 | 17 Jul 06 SHL Use Runtime_Error
|
---|
[373] | 15 | 26 Jul 06 SHL Use convert_nl_to_nul
|
---|
[441] | 16 | 15 Aug 06 SHL More error popups
|
---|
[519] | 17 | 01 Nov 06 SHL runemf2: temp fix for hung windows caused by termq errors
|
---|
[540] | 18 | 03 Nov 06 SHL runemf2: rework termination queue logic to work for multiple threads
|
---|
[552] | 19 | 07 Jan 07 GKY Move error strings etc. to string file
|
---|
[775] | 20 | 06 Aug 07 GKY Reduce DosSleep times (ticket 148)
|
---|
[793] | 21 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
[985] | 22 | 29 Feb 08 GKY Changes to enable user settable command line length
|
---|
| 23 | 29 Feb 08 GKY Refactor global command line variables to notebook.h
|
---|
[1021] | 24 | 26 May 08 SHL Use uiLineNumber correctly
|
---|
[1082] | 25 | 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory or pTmpDir and use MakeTempName
|
---|
[1375] | 26 | 03 Jan 09 GKY Check for system that is protectonly to gray out Dos/Win command lines and prevent
|
---|
[1394] | 27 | Dos/Win programs from being inserted into the execute dialog with message why.
|
---|
[78] | 28 |
|
---|
| 29 | ***********************************************************************/
|
---|
| 30 |
|
---|
[2] | 31 | #include <stdlib.h>
|
---|
| 32 | #include <stdarg.h>
|
---|
| 33 | #include <string.h>
|
---|
| 34 | #include <ctype.h>
|
---|
[330] | 35 |
|
---|
[907] | 36 | #define INCL_DOS
|
---|
| 37 | #define INCL_DOSERRORS
|
---|
| 38 | #define INCL_WIN
|
---|
[1162] | 39 | #define INCL_LONGLONG // dircnrs.h
|
---|
[907] | 40 |
|
---|
[1186] | 41 | #include "fm3dll.h"
|
---|
[1227] | 42 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
[1213] | 43 | #include "mkdir.h" // Data declaration(s)
|
---|
| 44 | #include "init.h" // Data declaration(s)
|
---|
| 45 | #include "mainwnd.h" // Data declaration(s)
|
---|
[2] | 46 | #include "fm3dlg.h"
|
---|
| 47 | #include "fm3str.h"
|
---|
[1162] | 48 | #include "errutil.h" // Dos_Error...
|
---|
| 49 | #include "strutil.h" // GetPString
|
---|
[985] | 50 | #include "notebook.h" //targetdirectory
|
---|
[907] | 51 | #include "pathutil.h"
|
---|
[1162] | 52 | #include "cmdline.h" // CmdLineDlgProc
|
---|
| 53 | #include "shadow.h" // RunSeamless
|
---|
| 54 | #include "systemf.h"
|
---|
| 55 | #include "strips.h" // convert_nl_to_nul, strip_lead_char
|
---|
| 56 | #include "dirs.h" // switch_to
|
---|
[1186] | 57 | #include "valid.h" // MakeFullName
|
---|
| 58 | #include "misc.h" // GetCmdSpec
|
---|
| 59 | #include "copyf.h" // MakeTempName
|
---|
| 60 | #include "wrappers.h" // xfopen
|
---|
[1039] | 61 | #include "fortify.h"
|
---|
[2] | 62 |
|
---|
[330] | 63 | static PSZ pszSrcFile = __FILE__;
|
---|
| 64 |
|
---|
[1162] | 65 | //static HAPP Exec(HWND hwndNotify, BOOL child, char *startdir, char *env,
|
---|
| 66 | // PROGTYPE * progt, ULONG fl, char *formatstring, ...);
|
---|
| 67 |
|
---|
[917] | 68 | /**
|
---|
| 69 | * Bring session foreground
|
---|
| 70 | * @return TRUE if OK, else FALSE
|
---|
| 71 | */
|
---|
[2] | 72 |
|
---|
[105] | 73 | BOOL ShowSession(HWND hwnd, PID pid)
|
---|
[78] | 74 | {
|
---|
[105] | 75 | HSWITCH hswitch;
|
---|
| 76 | SWCNTRL swctl;
|
---|
| 77 | ULONG rc;
|
---|
[2] | 78 |
|
---|
[519] | 79 | hswitch = WinQuerySwitchHandle(pid ? (HWND)0 : hwnd, pid);
|
---|
[441] | 80 | if (hswitch) {
|
---|
[105] | 81 | rc = WinQuerySwitchEntry(hswitch, &swctl);
|
---|
[441] | 82 | if (!rc) {
|
---|
[105] | 83 | if (swctl.idProcess == pid && swctl.uchVisibility == SWL_VISIBLE)
|
---|
[1394] | 84 | rc = WinSwitchToProgram(hswitch);
|
---|
[105] | 85 | if (!rc)
|
---|
[1394] | 86 | return TRUE;
|
---|
[105] | 87 | }
|
---|
| 88 | }
|
---|
| 89 | return FALSE;
|
---|
[2] | 90 | }
|
---|
| 91 |
|
---|
[917] | 92 | /**
|
---|
| 93 | * Invoke runemf2 for command and file/directory list
|
---|
| 94 | * @return command return code or
|
---|
| 95 | * -1 if runtime error or
|
---|
| 96 | * -2 if user cancels command line edit dialog
|
---|
| 97 | */
|
---|
[519] | 98 |
|
---|
[105] | 99 | int ExecOnList(HWND hwnd, char *command, int flags, char *tpath,
|
---|
[1394] | 100 | PSZ *list, PCSZ prompt, PCSZ pszCallingFile, UINT uiLineNumber)
|
---|
[78] | 101 | {
|
---|
[105] | 102 | /* executes the command once for all files in list */
|
---|
[2] | 103 |
|
---|
[1394] | 104 | CHAR path[CCHMAXPATH], *commandline, modpath[CCHMAXPATH], listfile[CCHMAXPATH],
|
---|
[105] | 105 | *p, *pp, drive, *file, *ext, *dot;
|
---|
[2] | 106 | register int x;
|
---|
[105] | 107 | BOOL spaces;
|
---|
[2] | 108 |
|
---|
[441] | 109 | if (!command || !*command) {
|
---|
[1398] | 110 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
[105] | 111 | return -1;
|
---|
[441] | 112 | }
|
---|
[989] | 113 | commandline = xmalloc(MaxComLineStrg + 1, pszSrcFile, __LINE__);
|
---|
[985] | 114 | if (!commandline)
|
---|
| 115 | return -1; //already complained
|
---|
[2] | 116 | *listfile = 0;
|
---|
[123] | 117 | bstrip(command);
|
---|
[2] | 118 |
|
---|
| 119 | *path = 0;
|
---|
[105] | 120 | if (tpath && *tpath)
|
---|
| 121 | strcpy(path, tpath);
|
---|
[441] | 122 | else if (*command != '<' || !strchr(command, '>')) {
|
---|
[105] | 123 | strcpy(path, command + (*command == '"'));
|
---|
| 124 | if (*command == '\"')
|
---|
| 125 | p = strchr(path, '\"');
|
---|
[2] | 126 | else
|
---|
[105] | 127 | p = strchr(path, ' ');
|
---|
| 128 | if (p)
|
---|
[2] | 129 | *p = 0;
|
---|
[105] | 130 | p = strrchr(path, '\\');
|
---|
| 131 | if (!p)
|
---|
| 132 | p = strrchr(path, ':');
|
---|
[441] | 133 | if (p) {
|
---|
| 134 | if (*p == ':') {
|
---|
[1394] | 135 | p++;
|
---|
| 136 | *p = '\\';
|
---|
| 137 | p++;
|
---|
[2] | 138 | }
|
---|
| 139 | *p = 0;
|
---|
| 140 | }
|
---|
| 141 | else
|
---|
| 142 | *path = 0;
|
---|
| 143 | }
|
---|
[441] | 144 | if (!*path) {
|
---|
[105] | 145 | if (list && list[0])
|
---|
| 146 | strcpy(path, list[0]);
|
---|
| 147 | p = strrchr(path, '\\');
|
---|
| 148 | if (!p)
|
---|
| 149 | p = strrchr(path, ':');
|
---|
[441] | 150 | if (p) {
|
---|
| 151 | if (*p == ':') {
|
---|
[1394] | 152 | p++;
|
---|
| 153 | *p = '\\';
|
---|
| 154 | p++;
|
---|
[2] | 155 | }
|
---|
| 156 | *p = 0;
|
---|
| 157 | }
|
---|
| 158 | else
|
---|
| 159 | *path = 0;
|
---|
| 160 | }
|
---|
| 161 | *modpath = 0;
|
---|
[105] | 162 | if (list && list[0])
|
---|
| 163 | strcpy(modpath, list[0]);
|
---|
| 164 | p = strrchr(modpath, '\\');
|
---|
| 165 | if (!p)
|
---|
| 166 | p = strrchr(modpath, ':');
|
---|
[441] | 167 | if (p) {
|
---|
| 168 | if (*p == ':') {
|
---|
[2] | 169 | p++;
|
---|
| 170 | *p = '\\';
|
---|
| 171 | p++;
|
---|
| 172 | }
|
---|
| 173 | *p = 0;
|
---|
| 174 | }
|
---|
| 175 | else
|
---|
| 176 | *modpath = 0;
|
---|
[105] | 177 | if (!*modpath)
|
---|
| 178 | strcpy(modpath, path);
|
---|
| 179 | if (*path)
|
---|
[2] | 180 | MakeFullName(path);
|
---|
[105] | 181 | if (*modpath)
|
---|
[2] | 182 | MakeFullName(modpath);
|
---|
[105] | 183 | if (IsFullName(path))
|
---|
| 184 | drive = toupper(*path);
|
---|
| 185 | else
|
---|
| 186 | drive = 0;
|
---|
[2] | 187 |
|
---|
[1162] | 188 | p = command; // substitue for special % sequences
|
---|
[2] | 189 |
|
---|
[105] | 190 | pp = commandline;
|
---|
| 191 | *commandline = 0;
|
---|
[441] | 192 | while (*p) {
|
---|
| 193 | if (*p == '%') {
|
---|
| 194 | switch (*(p + 1)) {
|
---|
[1162] | 195 | case '!': /* write list to file, add filename */
|
---|
[1394] | 196 | if (list) {
|
---|
| 197 | if (!*listfile) {
|
---|
| 198 | FILE *fp;
|
---|
[2] | 199 |
|
---|
[1082] | 200 |
|
---|
[1394] | 201 | strcpy(listfile, pTmpDir ? pTmpDir : pFM2SaveDirectory);
|
---|
| 202 | MakeTempName(listfile, "$FM2LI$T", 2);
|
---|
| 203 | fp = xfopen(listfile, "w",pszSrcFile,__LINE__);
|
---|
| 204 | if (fp) {
|
---|
| 205 | for (x = 0; list[x]; x++)
|
---|
| 206 | {
|
---|
| 207 | fputs(list[x], fp);
|
---|
| 208 | if (list[x + 1])
|
---|
| 209 | fputc('\n', fp);
|
---|
| 210 | }
|
---|
| 211 | fclose(fp);
|
---|
| 212 | }
|
---|
| 213 | }
|
---|
| 214 | strcpy(pp, listfile);
|
---|
| 215 | pp += strlen(listfile);
|
---|
| 216 | }
|
---|
| 217 | p += 2;
|
---|
| 218 | break;
|
---|
[2] | 219 |
|
---|
[1162] | 220 | case 'c': /* add name of command processor */
|
---|
[1394] | 221 | {
|
---|
| 222 | char *env = GetCmdSpec(FALSE);
|
---|
[2] | 223 |
|
---|
[1394] | 224 | if (needs_quoting(env) && !strchr(env, '\"')) {
|
---|
| 225 | *pp = '\"';
|
---|
| 226 | pp++;
|
---|
| 227 | spaces = TRUE;
|
---|
| 228 | }
|
---|
| 229 | else
|
---|
| 230 | spaces = FALSE;
|
---|
| 231 | strcpy(pp, env);
|
---|
| 232 | p += 2;
|
---|
| 233 | pp += strlen(env);
|
---|
| 234 | if (spaces) {
|
---|
| 235 | *pp = '\"';
|
---|
| 236 | pp++;
|
---|
| 237 | }
|
---|
| 238 | }
|
---|
| 239 | break;
|
---|
[2] | 240 |
|
---|
[1162] | 241 | case 't': /* add Target directory */
|
---|
[1394] | 242 | if (needs_quoting(targetdir) && !strchr(targetdir, '\"')) {
|
---|
| 243 | *pp = '\"';
|
---|
| 244 | pp++;
|
---|
| 245 | spaces = TRUE;
|
---|
| 246 | }
|
---|
| 247 | else
|
---|
| 248 | spaces = FALSE;
|
---|
| 249 | strcpy(pp, targetdir);
|
---|
| 250 | p += 2;
|
---|
| 251 | pp += strlen(targetdir);
|
---|
| 252 | if (spaces) {
|
---|
| 253 | *pp = '\"';
|
---|
| 254 | pp++;
|
---|
| 255 | }
|
---|
| 256 | break;
|
---|
[2] | 257 |
|
---|
[1162] | 258 | case '$': /* add drive letter */
|
---|
[1394] | 259 | if (drive)
|
---|
| 260 | *pp = drive;
|
---|
| 261 | else {
|
---|
| 262 | ULONG ulDriveNum = 3, ulDriveMap;
|
---|
[2] | 263 |
|
---|
[1394] | 264 | DosQCurDisk(&ulDriveNum, &ulDriveMap);
|
---|
| 265 | *pp = (char) (ulDriveNum + '@');
|
---|
| 266 | }
|
---|
| 267 | pp++;
|
---|
| 268 | p += 2;
|
---|
| 269 | break;
|
---|
[2] | 270 |
|
---|
[1162] | 271 | case 'U': /* add path of first list component */
|
---|
[105] | 272 | case 'u':
|
---|
[1394] | 273 | if (*modpath) {
|
---|
| 274 | if (needs_quoting(modpath) && !strchr(modpath, '\"')) {
|
---|
| 275 | spaces = TRUE;
|
---|
| 276 | *pp = '\"';
|
---|
| 277 | pp++;
|
---|
| 278 | }
|
---|
| 279 | else
|
---|
| 280 | spaces = FALSE;
|
---|
| 281 | if (*(p + 1) == 'u') {
|
---|
| 282 | strcpy(pp, modpath);
|
---|
| 283 | pp += strlen(modpath);
|
---|
| 284 | }
|
---|
| 285 | else {
|
---|
| 286 | strcpy(pp, modpath + 2);
|
---|
| 287 | pp += strlen(modpath + 2);
|
---|
| 288 | }
|
---|
| 289 | if (spaces) {
|
---|
| 290 | if (modpath[strlen(modpath) - 1] == '\\') {
|
---|
| 291 | *pp = '\\';
|
---|
| 292 | pp++;
|
---|
| 293 | }
|
---|
| 294 | *pp = '\"';
|
---|
| 295 | pp++;
|
---|
| 296 | }
|
---|
| 297 | }
|
---|
| 298 | else {
|
---|
| 299 | char temp[CCHMAXPATH];
|
---|
[2] | 300 |
|
---|
[1394] | 301 | strcpy(temp, pFM2SaveDirectory);
|
---|
| 302 | if (needs_quoting(temp) && !strchr(temp, '\"')) {
|
---|
| 303 | spaces = TRUE;
|
---|
| 304 | *pp = '\"';
|
---|
| 305 | pp++;
|
---|
| 306 | }
|
---|
| 307 | else
|
---|
| 308 | spaces = FALSE;
|
---|
| 309 | strcpy(pp, temp);
|
---|
| 310 | pp += strlen(temp);
|
---|
| 311 | if (spaces) {
|
---|
| 312 | if (temp[strlen(temp) - 1] == '\\') {
|
---|
| 313 | *pp = '\\';
|
---|
| 314 | pp++;
|
---|
| 315 | }
|
---|
| 316 | *pp = '\"';
|
---|
| 317 | pp++;
|
---|
| 318 | }
|
---|
| 319 | }
|
---|
| 320 | p += 2;
|
---|
| 321 | break;
|
---|
[2] | 322 |
|
---|
[1162] | 323 | case 'P': /* add path of execution */
|
---|
[105] | 324 | case 'p':
|
---|
[1394] | 325 | if (*path) {
|
---|
| 326 | if (needs_quoting(path) && !strchr(path, '\"')) {
|
---|
| 327 | spaces = TRUE;
|
---|
| 328 | *pp = '\"';
|
---|
| 329 | pp++;
|
---|
| 330 | }
|
---|
| 331 | else
|
---|
| 332 | spaces = FALSE;
|
---|
| 333 | if (*(p + 1) == 'p') {
|
---|
| 334 | strcpy(pp, path);
|
---|
| 335 | pp += strlen(path);
|
---|
| 336 | }
|
---|
| 337 | else {
|
---|
| 338 | strcpy(pp, path + 2);
|
---|
| 339 | pp += strlen(path + 2);
|
---|
| 340 | }
|
---|
| 341 | if (spaces) {
|
---|
| 342 | if (path[strlen(path) - 1] == '\\') {
|
---|
| 343 | *pp = '\\';
|
---|
| 344 | pp++;
|
---|
| 345 | }
|
---|
| 346 | *pp = '\"';
|
---|
| 347 | pp++;
|
---|
| 348 | }
|
---|
| 349 | }
|
---|
| 350 | else {
|
---|
| 351 | char temp[CCHMAXPATH];
|
---|
[2] | 352 |
|
---|
[1394] | 353 | strcpy(temp, pFM2SaveDirectory);
|
---|
| 354 | if (needs_quoting(temp) && !strchr(temp, '\"')) {
|
---|
| 355 | spaces = TRUE;
|
---|
| 356 | *pp = '\"';
|
---|
| 357 | pp++;
|
---|
| 358 | }
|
---|
| 359 | else
|
---|
| 360 | spaces = FALSE;
|
---|
| 361 | strcpy(pp, temp);
|
---|
| 362 | pp += strlen(temp);
|
---|
| 363 | if (spaces) {
|
---|
| 364 | if (temp[strlen(temp) - 1] == '\\') {
|
---|
| 365 | *pp = '\\';
|
---|
| 366 | pp++;
|
---|
| 367 | }
|
---|
| 368 | *pp = '\"';
|
---|
| 369 | pp++;
|
---|
| 370 | }
|
---|
| 371 | }
|
---|
| 372 | p += 2;
|
---|
| 373 | break;
|
---|
[2] | 374 |
|
---|
[105] | 375 | case 'D':
|
---|
[1394] | 376 | if (hwndMain) {
|
---|
| 377 | PCNRITEM pci;
|
---|
[2] | 378 |
|
---|
[1394] | 379 | pci = (PCNRITEM) WinSendMsg(WinWindowFromID(WinWindowFromID(
|
---|
| 380 | hwndTree, FID_CLIENT), TREE_CNR),
|
---|
| 381 | CM_QUERYRECORDEMPHASIS,
|
---|
| 382 | MPFROMLONG(CMA_FIRST),
|
---|
| 383 | MPFROMSHORT(CRA_CURSORED));
|
---|
| 384 | if (pci && (int) pci != -1 && *pci->pszFileName) {
|
---|
| 385 | if (needs_quoting(pci->pszFileName) &&
|
---|
| 386 | !strchr(pci->pszFileName, '\"'))
|
---|
| 387 | {
|
---|
| 388 | *pp = '\"';
|
---|
| 389 | pp++;
|
---|
| 390 | spaces = TRUE;
|
---|
| 391 | }
|
---|
| 392 | else
|
---|
| 393 | spaces = FALSE;
|
---|
| 394 | strcpy(pp, pci->pszFileName);
|
---|
| 395 | pp += strlen(pci->pszFileName);
|
---|
| 396 | if (spaces) {
|
---|
| 397 | *pp = '\"';
|
---|
| 398 | pp++;
|
---|
| 399 | }
|
---|
| 400 | }
|
---|
| 401 | }
|
---|
| 402 | p += 2;
|
---|
| 403 | break;
|
---|
[2] | 404 |
|
---|
[105] | 405 | case 'd':
|
---|
[1394] | 406 | if (hwndMain) {
|
---|
| 407 | HENUM henum;
|
---|
| 408 | char retstr[CCHMAXPATH];
|
---|
| 409 | HWND hwndC, hwndDir;
|
---|
| 410 | USHORT id;
|
---|
| 411 | BOOL first = TRUE;
|
---|
[2] | 412 |
|
---|
[1394] | 413 | henum = WinBeginEnumWindows(hwndMain);
|
---|
| 414 | while ((hwndC = WinGetNextWindow(henum)) != NULLHANDLE) {
|
---|
| 415 | if (hwndC != hwndTree) {
|
---|
| 416 | id = WinQueryWindowUShort(hwndC, QWS_ID);
|
---|
| 417 | if (id) {
|
---|
| 418 | hwndDir = WinWindowFromID(hwndC, FID_CLIENT);
|
---|
| 419 | if (hwndDir) {
|
---|
| 420 | hwndDir = WinWindowFromID(hwndDir, DIR_CNR);
|
---|
| 421 | if (hwndDir) {
|
---|
| 422 | *retstr = 0;
|
---|
| 423 | WinSendMsg(hwndC, UM_CONTAINERDIR, MPFROMP(retstr), MPVOID);
|
---|
| 424 | if (*retstr) {
|
---|
| 425 | if (!first) {
|
---|
| 426 | *pp = ' ';
|
---|
| 427 | pp++;
|
---|
| 428 | }
|
---|
| 429 | first = FALSE;
|
---|
| 430 | if (needs_quoting(retstr) && !strchr(retstr, '\"')) {
|
---|
| 431 | *pp = '\"';
|
---|
| 432 | pp++;
|
---|
| 433 | spaces = TRUE;
|
---|
| 434 | }
|
---|
| 435 | else
|
---|
| 436 | spaces = FALSE;
|
---|
| 437 | strcpy(pp, retstr);
|
---|
| 438 | pp += strlen(retstr);
|
---|
| 439 | if (spaces) {
|
---|
| 440 | *pp = '\"';
|
---|
| 441 | pp++;
|
---|
| 442 | }
|
---|
| 443 | }
|
---|
| 444 | }
|
---|
| 445 | }
|
---|
| 446 | }
|
---|
| 447 | }
|
---|
| 448 | }
|
---|
| 449 | WinEndEnumWindows(henum);
|
---|
| 450 | }
|
---|
| 451 | p += 2;
|
---|
| 452 | break;
|
---|
[2] | 453 |
|
---|
[105] | 454 | case '%':
|
---|
[1394] | 455 | *pp = '%';
|
---|
| 456 | pp++;
|
---|
| 457 | p += 2;
|
---|
| 458 | break;
|
---|
[2] | 459 |
|
---|
[105] | 460 | case 'R':
|
---|
| 461 | case 'F':
|
---|
| 462 | case 'A':
|
---|
| 463 | case 'r':
|
---|
| 464 | case 'f':
|
---|
| 465 | case 'a':
|
---|
| 466 | case 'e':
|
---|
[1394] | 467 | if (list) {
|
---|
| 468 | for (x = 0; list[x]; x++)
|
---|
| 469 | {
|
---|
| 470 | file = strrchr(list[x], '\\');
|
---|
| 471 | if (!file)
|
---|
| 472 | file = strrchr(list[x], ':');
|
---|
| 473 | if (file)
|
---|
| 474 | file++;
|
---|
| 475 | else
|
---|
| 476 | file = list[x];
|
---|
| 477 | ext = strrchr(file, '.');
|
---|
| 478 | dot = ext;
|
---|
| 479 | if (ext)
|
---|
| 480 | ext++;
|
---|
| 481 | switch (*(p + 1)) {
|
---|
| 482 | case 'R':
|
---|
| 483 | case 'r':
|
---|
| 484 | if (pp + strlen(list[x]) > commandline + MaxComLineStrg)
|
---|
| 485 | goto BreakOut;
|
---|
| 486 | if (*(p + 1) == 'r') {
|
---|
| 487 | strcpy(pp, list[x]);
|
---|
| 488 | pp += strlen(list[x]);
|
---|
| 489 | }
|
---|
| 490 | else {
|
---|
| 491 | strcpy(pp, list[x] + 2);
|
---|
| 492 | pp += strlen(list[x] + 2);
|
---|
| 493 | }
|
---|
| 494 | break;
|
---|
[2] | 495 |
|
---|
[1394] | 496 | case 'F':
|
---|
| 497 | case 'f':
|
---|
| 498 | if (*(p + 1) == 'F' && dot)
|
---|
| 499 | *dot = 0;
|
---|
| 500 | if (pp + strlen(file) > commandline + MaxComLineStrg)
|
---|
| 501 | goto BreakOut;
|
---|
| 502 | if (needs_quoting(file)) {
|
---|
| 503 | spaces = TRUE;
|
---|
| 504 | *pp = '\"';
|
---|
| 505 | pp++;
|
---|
| 506 | }
|
---|
| 507 | else
|
---|
| 508 | spaces = FALSE;
|
---|
| 509 | strcpy(pp, file);
|
---|
| 510 | pp += strlen(file);
|
---|
| 511 | if (*(p + 1) == 'F' && dot)
|
---|
| 512 | *dot = '.';
|
---|
| 513 | if (spaces) {
|
---|
| 514 | if (*(pp - 1) != '\"') {
|
---|
| 515 | *pp = '\"';
|
---|
| 516 | pp++;
|
---|
| 517 | }
|
---|
| 518 | }
|
---|
| 519 | break;
|
---|
[2] | 520 |
|
---|
[1394] | 521 | case 'A':
|
---|
| 522 | case 'a':
|
---|
| 523 | if (pp + strlen(list[x]) > commandline + MaxComLineStrg)
|
---|
| 524 | goto BreakOut;
|
---|
| 525 | if (needs_quoting(list[x]) && !strchr(list[x], '\"')) {
|
---|
| 526 | spaces = TRUE;
|
---|
| 527 | *pp = '\"';
|
---|
| 528 | pp++;
|
---|
| 529 | }
|
---|
| 530 | else
|
---|
| 531 | spaces = FALSE;
|
---|
| 532 | if (*(p + 1) == 'a') {
|
---|
| 533 | strcpy(pp, list[x]);
|
---|
| 534 | pp += strlen(list[x]);
|
---|
| 535 | }
|
---|
| 536 | else {
|
---|
| 537 | strcpy(pp, list[x] + 2);
|
---|
| 538 | pp += strlen(list[x] + 2);
|
---|
| 539 | }
|
---|
| 540 | if (spaces) {
|
---|
| 541 | if (list[x][strlen(list[x]) - 1] == '\\') {
|
---|
| 542 | *pp = '\\';
|
---|
| 543 | pp++;
|
---|
| 544 | }
|
---|
| 545 | *pp = '\"';
|
---|
| 546 | pp++;
|
---|
| 547 | }
|
---|
| 548 | break;
|
---|
[2] | 549 |
|
---|
[1394] | 550 | case 'e':
|
---|
| 551 | if (ext) {
|
---|
| 552 | if (pp + strlen(ext) > commandline + MaxComLineStrg)
|
---|
| 553 | goto BreakOut;
|
---|
| 554 | if (needs_quoting(ext)) {
|
---|
| 555 | spaces = TRUE;
|
---|
| 556 | *pp = '\"';
|
---|
| 557 | pp++;
|
---|
| 558 | }
|
---|
| 559 | else
|
---|
| 560 | spaces = FALSE;
|
---|
| 561 | strcpy(pp, ext);
|
---|
| 562 | pp += strlen(ext);
|
---|
| 563 | if (spaces) {
|
---|
| 564 | if (*(pp - 1) != '\"') {
|
---|
| 565 | *pp = '\"';
|
---|
| 566 | pp++;
|
---|
| 567 | }
|
---|
| 568 | }
|
---|
| 569 | }
|
---|
| 570 | break;
|
---|
| 571 | }
|
---|
| 572 | if (list[x + 1]) {
|
---|
| 573 | *pp = ' ';
|
---|
| 574 | pp++;
|
---|
| 575 | }
|
---|
| 576 | }
|
---|
| 577 | }
|
---|
| 578 | p += 2;
|
---|
| 579 | break;
|
---|
[2] | 580 |
|
---|
[105] | 581 | default:
|
---|
[1394] | 582 | *pp = *p;
|
---|
| 583 | p++;
|
---|
| 584 | pp++;
|
---|
| 585 | break;
|
---|
[105] | 586 | }
|
---|
| 587 | }
|
---|
[441] | 588 | else {
|
---|
[105] | 589 | *pp = *p;
|
---|
| 590 | pp++;
|
---|
| 591 | p++;
|
---|
| 592 | }
|
---|
| 593 | *pp = 0;
|
---|
| 594 | }
|
---|
| 595 |
|
---|
[2] | 596 | BreakOut:
|
---|
| 597 |
|
---|
[105] | 598 | {
|
---|
| 599 | EXECARGS ex;
|
---|
| 600 | ULONG size;
|
---|
| 601 | int ret;
|
---|
[2] | 602 |
|
---|
[105] | 603 | memset(&ex, 0, sizeof(EXECARGS));
|
---|
| 604 | size = sizeof(ex.environment) - 1;
|
---|
| 605 | PrfQueryProfileData(fmprof, FM3Str, command, ex.environment, &size);
|
---|
[441] | 606 | if (flags & PROMPT) {
|
---|
| 607 | /* allow editing command line */
|
---|
[105] | 608 | ex.flags = (flags & (~PROMPT));
|
---|
| 609 | ex.commandline = commandline;
|
---|
| 610 | strcpy(ex.path, path);
|
---|
| 611 | if (prompt)
|
---|
[1394] | 612 | strcpy(ex.title, prompt);
|
---|
[105] | 613 | ret = WinDlgBox(HWND_DESKTOP, hwnd, CmdLineDlgProc, FM3ModHandle,
|
---|
[1394] | 614 | EXEC_FRAME, &ex);
|
---|
[985] | 615 | if (ret != 1) {
|
---|
[1394] | 616 | free(commandline);
|
---|
| 617 | return (ret == 0) ? -1 : -2;
|
---|
[985] | 618 | }
|
---|
[105] | 619 | }
|
---|
| 620 | else
|
---|
| 621 | ex.flags = flags;
|
---|
| 622 | ex.flags &= (~PROMPT);
|
---|
[1014] | 623 | ret = runemf2(ex.flags, hwnd, pszCallingFile, uiLineNumber, path,
|
---|
[1394] | 624 | (*ex.environment) ? ex.environment : NULL,
|
---|
| 625 | "%s", commandline);
|
---|
[1039] | 626 | free(commandline);
|
---|
[1014] | 627 | return ret;
|
---|
[105] | 628 | }
|
---|
[2] | 629 | }
|
---|
| 630 |
|
---|
[917] | 631 | /** Run requested app
|
---|
| 632 | * @return application return code or -1 if problem starting app
|
---|
| 633 | */
|
---|
[441] | 634 |
|
---|
[888] | 635 | int runemf2(int type, HWND hwnd, PCSZ pszCallingFile, UINT uiLineNumber,
|
---|
[1394] | 636 | char *pszDirectory, char *pszEnvironment,
|
---|
| 637 | char *formatstring,...)
|
---|
[78] | 638 | {
|
---|
[920] | 639 | /** example:
|
---|
[105] | 640 |
|
---|
[2] | 641 | * status = runemf2(SEPARATE | WINDOWED,
|
---|
[888] | 642 | * hwnd, pszCallingFile, __LINE__,
|
---|
[2] | 643 | * NullStr,
|
---|
| 644 | * NULL,
|
---|
| 645 | * "%s /C %s",
|
---|
| 646 | * getenv("COMSPEC"),
|
---|
| 647 | * batchfilename);
|
---|
[105] | 648 | *
|
---|
| 649 | * use (HWND)0 for hwnd if window handle not handy.
|
---|
[888] | 650 | * pszCallingFile and __LINE__ are used to determine caller for easier error tracking
|
---|
[105] | 651 | */
|
---|
[2] | 652 |
|
---|
[920] | 653 | /**
|
---|
[1252] | 654 | * type bitmapped flag -- see systemf.h
|
---|
[2] | 655 | */
|
---|
| 656 |
|
---|
[105] | 657 | va_list parguments;
|
---|
| 658 | int ret = -1;
|
---|
[540] | 659 | RESULTCODES results;
|
---|
[519] | 660 | STARTDATA sdata;
|
---|
[105] | 661 | REQUESTDATA rq;
|
---|
[562] | 662 | ULONG ulSessID;
|
---|
| 663 | ULONG ulLength;
|
---|
| 664 | UINT ctr;
|
---|
| 665 | ULONG ulAppType;
|
---|
[105] | 666 | PID sessPID;
|
---|
| 667 | BOOL wasquote;
|
---|
[1438] | 668 | char *p, *pszPgm, *pszArgs = NULL;
|
---|
| 669 | char szObject[32] = "";
|
---|
| 670 | char szSavedir[CCHMAXPATH];
|
---|
[540] | 671 | BOOL useTermQ = FALSE;
|
---|
| 672 | char szTempdir[CCHMAXPATH];
|
---|
[1369] | 673 | BOOL fNoErrorMsg = FALSE;
|
---|
[540] | 674 |
|
---|
[519] | 675 | typedef struct {
|
---|
| 676 | USHORT usSessID;
|
---|
| 677 | USHORT usRC;
|
---|
| 678 | } TERMINFO;
|
---|
| 679 |
|
---|
[540] | 680 | TERMINFO *pTermInfo;
|
---|
[105] | 681 | BYTE bPriority;
|
---|
| 682 | APIRET rc;
|
---|
[519] | 683 | PIB *ppib;
|
---|
| 684 | TIB *ptib;
|
---|
[2] | 685 |
|
---|
[540] | 686 | // Shared by all threads
|
---|
| 687 | # define TERMQ_BASE_NAME "\\QUEUES\\FM3WAIT"
|
---|
| 688 | static char szTermQName[30];
|
---|
| 689 | static HQUEUE hTermQ;
|
---|
[1271] | 690 | static HEV hTermQSem;
|
---|
[540] | 691 |
|
---|
| 692 | if (pszDirectory && *pszDirectory) {
|
---|
| 693 | if (!DosQueryPathInfo(pszDirectory,
|
---|
[1394] | 694 | FIL_QUERYFULLNAME,
|
---|
| 695 | szTempdir,
|
---|
| 696 | sizeof(szTempdir)))
|
---|
[540] | 697 | pszDirectory = szTempdir;
|
---|
[105] | 698 | }
|
---|
[2] | 699 |
|
---|
[105] | 700 | if (!hwnd)
|
---|
| 701 | hwnd = HWND_DESKTOP;
|
---|
[2] | 702 |
|
---|
[1438] | 703 | rc = xDosAllocMem((PVOID)&pszPgm,
|
---|
| 704 | MaxComLineStrg,
|
---|
| 705 | PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE);
|
---|
[330] | 706 | if (rc) {
|
---|
| 707 | Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY));
|
---|
[105] | 708 | return -1;
|
---|
[330] | 709 | }
|
---|
[2] | 710 |
|
---|
[540] | 711 | *szSavedir = 0;
|
---|
[2] | 712 |
|
---|
[540] | 713 | *pszPgm = 0;
|
---|
[105] | 714 | va_start(parguments,
|
---|
[1394] | 715 | formatstring);
|
---|
[540] | 716 | vsprintf(pszPgm,
|
---|
[1394] | 717 | formatstring,
|
---|
| 718 | parguments);
|
---|
[105] | 719 | va_end(parguments);
|
---|
[906] | 720 |
|
---|
[540] | 721 | if (pszEnvironment) {
|
---|
| 722 | p = &pszEnvironment[strlen(pszEnvironment)] + 1;
|
---|
[105] | 723 | *p = 0;
|
---|
[540] | 724 | p = pszEnvironment;
|
---|
[373] | 725 | while ((p = convert_nl_to_nul(p)) != NULL)
|
---|
| 726 | ; // loop
|
---|
[105] | 727 | }
|
---|
[2] | 728 |
|
---|
[1369] | 729 | if (!stricmp(pszCallingFile, "init.c"))
|
---|
| 730 | fNoErrorMsg = TRUE;
|
---|
| 731 |
|
---|
[540] | 732 | if (!*pszPgm) {
|
---|
[105] | 733 | p = GetCmdSpec(FALSE);
|
---|
[540] | 734 | strcpy(pszPgm, p);
|
---|
| 735 | if (!*pszPgm) {
|
---|
[1398] | 736 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
---|
[105] | 737 | return -1;
|
---|
[441] | 738 | }
|
---|
[105] | 739 | }
|
---|
[2] | 740 |
|
---|
[540] | 741 | if (*pszPgm) {
|
---|
| 742 | if (*pszPgm == '<' && strchr(pszPgm, '>')) {
|
---|
[441] | 743 | /* is a workplace object */
|
---|
[105] | 744 | HOBJECT hWPSObject;
|
---|
| 745 | char temp;
|
---|
[2] | 746 |
|
---|
[540] | 747 | p = strchr(pszPgm, '>');
|
---|
[105] | 748 | p++;
|
---|
| 749 | temp = *p;
|
---|
[330] | 750 | if (temp) {
|
---|
[1438] | 751 | rc = xDosAllocMem((PVOID)&pszArgs,
|
---|
| 752 | MaxComLineStrg * 2,
|
---|
| 753 | PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE);
|
---|
[1394] | 754 | if (rc)
|
---|
| 755 | Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY));
|
---|
[330] | 756 | }
|
---|
[105] | 757 | else
|
---|
[1394] | 758 | pszArgs = NULL;
|
---|
[105] | 759 | *p = 0;
|
---|
| 760 | /* Find the handle of the WPS object */
|
---|
[540] | 761 | hWPSObject = WinQueryObject(pszPgm);
|
---|
[105] | 762 | *p = temp;
|
---|
[441] | 763 | if (hWPSObject != NULLHANDLE) {
|
---|
[1394] | 764 | if (pszArgs && *p) {
|
---|
| 765 | sprintf(pszArgs,"OPEN=DEFAULT;PARAMETERS=\"%s\"",p);
|
---|
| 766 | WinSetObjectData(hWPSObject,pszArgs);
|
---|
| 767 | }
|
---|
| 768 | else
|
---|
| 769 | WinSetObjectData(hWPSObject,"OPEN=DEFAULT");
|
---|
| 770 | ret = 0;
|
---|
[105] | 771 | }
|
---|
| 772 | goto ObjectInterrupt;
|
---|
| 773 | }
|
---|
[2] | 774 |
|
---|
[773] | 775 | if ((type & RUNTYPE_MASK) == SYNCHRONOUS ||
|
---|
[1394] | 776 | (type & RUNTYPE_MASK) == ASYNCHRONOUS ||
|
---|
| 777 | (type & RUNTYPE_MASK) == DETACHED)
|
---|
[105] | 778 | {
|
---|
[540] | 779 | strip_lead_char(" \t", pszPgm);
|
---|
| 780 | p = pszPgm;
|
---|
[105] | 781 | wasquote = FALSE;
|
---|
| 782 | while (*p &&
|
---|
[1394] | 783 | (wasquote ||
|
---|
| 784 | (*p != ' ' &&
|
---|
| 785 | *p != '\t')))
|
---|
[105] | 786 | {
|
---|
[1394] | 787 | if (*p == '\"') {
|
---|
| 788 | if (!wasquote) {
|
---|
| 789 | wasquote = TRUE;
|
---|
| 790 | memmove(p,
|
---|
| 791 | p + 1,
|
---|
| 792 | strlen(p));
|
---|
| 793 | while (*p == ' ' ||
|
---|
| 794 | *p == '\t')
|
---|
| 795 | p++;
|
---|
| 796 | }
|
---|
| 797 | else {
|
---|
| 798 | memmove(p,
|
---|
| 799 | p + 1,
|
---|
| 800 | strlen(p));
|
---|
| 801 | break;
|
---|
| 802 | }
|
---|
| 803 | }
|
---|
| 804 | else
|
---|
| 805 | p++;
|
---|
[105] | 806 | }
|
---|
[441] | 807 | if (*p) {
|
---|
[1394] | 808 | *p = 0;
|
---|
| 809 | p++;
|
---|
[105] | 810 | }
|
---|
| 811 | else
|
---|
[1394] | 812 | p = pszPgm;
|
---|
[1162] | 813 | p[strlen(p) + 1] = 0; /* double-terminate args */
|
---|
[540] | 814 | if (*pszPgm) {
|
---|
[1394] | 815 | if (!strchr(pszPgm, '\\') &&
|
---|
| 816 | !strchr(pszPgm, ':') &&
|
---|
| 817 | pszDirectory &&
|
---|
| 818 | *pszDirectory)
|
---|
| 819 | {
|
---|
| 820 | strcpy(szSavedir, pFM2SaveDirectory);
|
---|
| 821 | switch_to(pszDirectory);
|
---|
| 822 | }
|
---|
| 823 | rc = DosQueryAppType(pszPgm,&ulAppType);
|
---|
| 824 | if (!strchr(pszPgm, '\\') &&
|
---|
| 825 | !strchr(pszPgm, ':') &&
|
---|
| 826 | pszDirectory &&
|
---|
| 827 | *pszDirectory)
|
---|
| 828 | switch_to(szSavedir);
|
---|
| 829 | if (rc) {
|
---|
| 830 | Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,
|
---|
| 831 | GetPString(IDS_DOSQAPPTYPEFAILEDTEXT),
|
---|
| 832 | pszPgm, pszCallingFile, uiLineNumber); // 26 May 08 SHL
|
---|
| 833 | DosFreeMem(pszPgm);
|
---|
| 834 | if (pszArgs)
|
---|
| 835 | DosFreeMem(pszArgs);
|
---|
| 836 | return -1;
|
---|
| 837 | }
|
---|
| 838 | if (ulAppType) {
|
---|
| 839 | if (ulAppType & FAPPTYP_DLL || ulAppType & FAPPTYP_VIRTDRV ||
|
---|
| 840 | ulAppType & FAPPTYP_PHYSDRV || ulAppType & FAPPTYP_PROTDLL)
|
---|
| 841 | {
|
---|
| 842 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 843 | GetPString(IDS_APPTYPEUNEXPECTEDTEXT),
|
---|
| 844 | ulAppType, pszPgm, pszCallingFile, uiLineNumber); // 26 May 08 SHL
|
---|
| 845 | if (pszPgm)
|
---|
| 846 | DosFreeMem(pszPgm);
|
---|
| 847 | if (pszArgs)
|
---|
| 848 | DosFreeMem(pszArgs);
|
---|
| 849 | return -1;
|
---|
| 850 | }
|
---|
| 851 | if (ulAppType & FAPPTYP_DOS || ulAppType & FAPPTYP_WINDOWSREAL ||
|
---|
| 852 | ulAppType & FAPPTYP_WINDOWSPROT || ulAppType & FAPPTYP_WINDOWSPROT31)
|
---|
| 853 | {
|
---|
| 854 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 855 | GetPString(IDS_APPTYPEUNEXPECTEDTEXT),
|
---|
| 856 | ulAppType, pszPgm, pszCallingFile, uiLineNumber); // 26 May 08 SHL
|
---|
| 857 | if (pszPgm)
|
---|
| 858 | DosFreeMem(pszPgm);
|
---|
| 859 | if (pszArgs)
|
---|
| 860 | DosFreeMem(pszArgs);
|
---|
| 861 | return -1;
|
---|
| 862 | }
|
---|
| 863 | }
|
---|
| 864 | memset(&results, 0, sizeof(results));
|
---|
| 865 | if (pszDirectory && *pszDirectory) {
|
---|
| 866 | strcpy(szSavedir, pFM2SaveDirectory);
|
---|
| 867 | switch_to(pszDirectory);
|
---|
| 868 | }
|
---|
| 869 | ret = DosExecPgm(szObject, sizeof(szObject),
|
---|
| 870 | ((type & RUNTYPE_MASK) == ASYNCHRONOUS ? EXEC_ASYNC : 0) +
|
---|
| 871 | ((type & RUNTYPE_MASK) == DETACHED ? EXEC_BACKGROUND : 0),
|
---|
| 872 | pszPgm, pszEnvironment, &results, pszPgm);
|
---|
| 873 | if (pszDirectory && *pszDirectory)
|
---|
| 874 | switch_to(szSavedir);
|
---|
| 875 | if (ret && !fNoErrorMsg) {
|
---|
| 876 | Dos_Error(MB_ENTER,ret,hwnd,pszSrcFile,__LINE__,
|
---|
| 877 | GetPString(IDS_DOSEXECPGMFAILEDTEXT), pszPgm,
|
---|
| 878 | pszCallingFile, uiLineNumber); // 26 May 08 SHL
|
---|
| 879 | }
|
---|
[105] | 880 | }
|
---|
| 881 | }
|
---|
[441] | 882 | else {
|
---|
[519] | 883 | if (~type & FULLSCREEN)
|
---|
[1394] | 884 | type |= WINDOWED;
|
---|
[1438] | 885 | rc = xDosAllocMem((PVOID) & pszArgs, MaxComLineStrg * 2,
|
---|
| 886 | PAG_COMMIT | OBJ_TILE | PAG_READ | PAG_WRITE);
|
---|
[441] | 887 | if (rc) {
|
---|
[1394] | 888 | Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,GetPString(IDS_OUTOFMEMORY));
|
---|
| 889 | DosFreeMem(pszPgm);
|
---|
| 890 | return -1;
|
---|
[105] | 891 | }
|
---|
[540] | 892 | *pszArgs = 0;
|
---|
| 893 | memset(&sdata, 0, sizeof(sdata));
|
---|
| 894 | strip_lead_char(" \t", pszPgm);
|
---|
| 895 | p = pszPgm;
|
---|
[105] | 896 | wasquote = FALSE;
|
---|
[441] | 897 | while (*p && (wasquote || (*p != ' ' && *p != '\t'))) {
|
---|
[1394] | 898 | if (*p == '\"') {
|
---|
| 899 | if (!wasquote) {
|
---|
| 900 | wasquote = TRUE;
|
---|
| 901 | memmove(p, p + 1, strlen(p));
|
---|
| 902 | while (*p == ' ' || *p == '\t')
|
---|
| 903 | p++;
|
---|
| 904 | }
|
---|
| 905 | else {
|
---|
| 906 | memmove(p, p + 1, strlen(p));
|
---|
| 907 | break;
|
---|
| 908 | }
|
---|
| 909 | }
|
---|
| 910 | else
|
---|
| 911 | p++;
|
---|
[540] | 912 | } // while
|
---|
[441] | 913 | if (*p) {
|
---|
[1394] | 914 | *p = 0;
|
---|
| 915 | p++;
|
---|
[105] | 916 | }
|
---|
| 917 | else
|
---|
[1394] | 918 | p = NullStr;
|
---|
[105] | 919 | if (*p)
|
---|
[1394] | 920 | strcpy(pszArgs, p);
|
---|
[2] | 921 |
|
---|
[540] | 922 | p = strrchr(pszPgm, '.');
|
---|
[441] | 923 | if (p) {
|
---|
[1394] | 924 | char temp[CCHMAXPATH + 1];
|
---|
[2] | 925 |
|
---|
[1398] | 926 | if (!stricmp(p, PCSZ_DOTBAT)) {
|
---|
| 927 | if (!fProtectOnly) {
|
---|
| 928 | strcpy(temp, pszPgm);
|
---|
| 929 | strcpy(pszPgm, pszArgs);
|
---|
| 930 | strcpy(pszArgs, "/C ");
|
---|
| 931 | strcat(pszArgs, temp);
|
---|
| 932 | strcat(pszArgs, " ");
|
---|
| 933 | strcat(pszArgs, pszPgm);
|
---|
| 934 | strcpy(pszPgm, GetCmdSpec(TRUE)); // DOS
|
---|
| 935 | }
|
---|
| 936 | else
|
---|
| 937 | saymsg(MB_OK,
|
---|
| 938 | HWND_DESKTOP,
|
---|
| 939 | NullStr,
|
---|
| 940 | GetPString(IDS_NOTPROTECTONLYEXE),
|
---|
| 941 | pszPgm);
|
---|
[1394] | 942 | }
|
---|
[1398] | 943 | else if (!stricmp(p, PCSZ_DOTCMD) || !stricmp(p, PCSZ_DOTBTM)) {
|
---|
[1394] | 944 | // Assume 4OS2 is BTM
|
---|
| 945 | strcpy(temp, pszPgm);
|
---|
| 946 | strcpy(pszPgm, pszArgs);
|
---|
| 947 | strcpy(pszArgs, "/C ");
|
---|
| 948 | strcat(pszArgs, temp);
|
---|
| 949 | strcat(pszArgs, " ");
|
---|
| 950 | strcat(pszArgs, pszPgm);
|
---|
| 951 | strcpy(pszPgm, GetCmdSpec(FALSE)); // OS/2
|
---|
| 952 | }
|
---|
[105] | 953 | }
|
---|
[2] | 954 |
|
---|
[888] | 955 | // goddamned OS/2 limit
|
---|
[2] | 956 |
|
---|
[540] | 957 | if (strlen(pszPgm) + strlen(pszArgs) > 1024)
|
---|
[1394] | 958 | pszArgs[1024 - strlen(pszPgm)] = 0;
|
---|
[2] | 959 |
|
---|
[540] | 960 | if (!strchr(pszPgm, '\\') &&
|
---|
[1394] | 961 | !strchr(pszPgm, ':') &&
|
---|
| 962 | pszDirectory &&
|
---|
| 963 | *pszDirectory)
|
---|
[105] | 964 | {
|
---|
[1394] | 965 | strcpy(szSavedir, pFM2SaveDirectory);
|
---|
| 966 | switch_to(pszDirectory);
|
---|
[105] | 967 | }
|
---|
[562] | 968 | rc = DosQueryAppType(pszPgm,&ulAppType);
|
---|
[540] | 969 | if (!strchr(pszPgm, '\\') &&
|
---|
[1394] | 970 | !strchr(pszPgm, ':') &&
|
---|
| 971 | pszDirectory &&
|
---|
| 972 | *pszDirectory)
|
---|
| 973 | switch_to(szSavedir);
|
---|
[917] | 974 | if (rc) {
|
---|
[1394] | 975 | Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,
|
---|
| 976 | GetPString(IDS_DOSQAPPTYPEFAILEDTEXT),
|
---|
| 977 | pszPgm, pszCallingFile, uiLineNumber); // 26 May 08 SHL
|
---|
| 978 | DosFreeMem(pszPgm);
|
---|
| 979 | if (pszArgs)
|
---|
| 980 | DosFreeMem(pszArgs);
|
---|
| 981 | return -1;
|
---|
[105] | 982 | }
|
---|
[2] | 983 |
|
---|
[562] | 984 | if (ulAppType) {
|
---|
[1394] | 985 | if (ulAppType & (FAPPTYP_DLL | FAPPTYP_VIRTDRV | FAPPTYP_PHYSDRV | FAPPTYP_PROTDLL))
|
---|
| 986 | {
|
---|
| 987 | Runtime_Error(pszSrcFile, __LINE__,
|
---|
| 988 | GetPString(IDS_APPTYPEUNEXPECTEDTEXT),
|
---|
| 989 | ulAppType, pszPgm, pszCallingFile, uiLineNumber); // 26 May 08 SHL
|
---|
| 990 | DosFreeMem(pszPgm);
|
---|
| 991 | if (pszArgs)
|
---|
| 992 | DosFreeMem(pszArgs);
|
---|
| 993 | return -1;
|
---|
| 994 | }
|
---|
| 995 | ulAppType &= ~FAPPTYP_BOUND;
|
---|
| 996 | if (ulAppType & (FAPPTYP_DOS | FAPPTYP_WINDOWSREAL | FAPPTYP_WINDOWSPROT | FAPPTYP_WINDOWSPROT31))
|
---|
| 997 | {
|
---|
| 998 | if (ulAppType & (FAPPTYP_WINDOWSREAL | FAPPTYP_WINDOWSPROT | FAPPTYP_WINDOWSPROT31))
|
---|
| 999 | {
|
---|
| 1000 | if (~type & FULLSCREEN &&
|
---|
| 1001 | ulAppType & (FAPPTYP_WINDOWSREAL | FAPPTYP_WINDOWSPROT | FAPPTYP_WINDOWSPROT31))
|
---|
| 1002 | {
|
---|
| 1003 | ret = RunSeamless(pszPgm, pszArgs, hwnd);
|
---|
| 1004 | if (pszPgm)
|
---|
| 1005 | DosFreeMem(pszPgm);
|
---|
| 1006 | if (pszArgs)
|
---|
| 1007 | DosFreeMem(pszArgs);
|
---|
| 1008 | return ret ? 0 : -1;
|
---|
| 1009 | }
|
---|
| 1010 | else {
|
---|
| 1011 | strcat(pszPgm, " ");
|
---|
| 1012 | strcat(pszPgm, pszArgs);
|
---|
| 1013 | *pszArgs = 0;
|
---|
| 1014 | if (ulAppType & (FAPPTYP_WINDOWSPROT | FAPPTYP_WINDOWSREAL | FAPPTYP_WINDOWSPROT31))
|
---|
| 1015 | strcat(pszArgs, "/3 ");
|
---|
| 1016 | strcat(pszArgs, pszPgm);
|
---|
| 1017 | strcpy(pszPgm, "WINOS2.COM");
|
---|
| 1018 | }
|
---|
| 1019 | }
|
---|
| 1020 | else {
|
---|
| 1021 | if (~type & FULLSCREEN) {
|
---|
| 1022 | type |= WINDOWED;
|
---|
| 1023 | ulAppType = SSF_TYPE_WINDOWEDVDM;
|
---|
| 1024 | }
|
---|
| 1025 | else {
|
---|
| 1026 | type &= ~WINDOWED;
|
---|
| 1027 | ulAppType = SSF_TYPE_VDM;
|
---|
| 1028 | }
|
---|
| 1029 | }
|
---|
| 1030 | }
|
---|
| 1031 | else if (ulAppType & FAPPTYP_32BIT) {
|
---|
| 1032 | ulAppType &= ~FAPPTYP_32BIT;
|
---|
| 1033 | if (ulAppType == FAPPTYP_WINDOWAPI)
|
---|
| 1034 | ulAppType = SSF_TYPE_PM;
|
---|
| 1035 | else if (ulAppType == FAPPTYP_WINDOWCOMPAT)
|
---|
| 1036 | ulAppType = SSF_TYPE_WINDOWABLEVIO;
|
---|
| 1037 | else if (ulAppType == FAPPTYP_NOTWINDOWCOMPAT) {
|
---|
| 1038 | ulAppType = SSF_TYPE_FULLSCREEN;
|
---|
| 1039 | type &= ~WINDOWED;
|
---|
| 1040 | type |= FULLSCREEN;
|
---|
| 1041 | }
|
---|
| 1042 | else /* ? */
|
---|
| 1043 | ulAppType = SSF_TYPE_WINDOWABLEVIO;
|
---|
| 1044 | }
|
---|
| 1045 | else if (ulAppType == FAPPTYP_WINDOWAPI)
|
---|
| 1046 | ulAppType = SSF_TYPE_PM;
|
---|
| 1047 | else if (ulAppType == FAPPTYP_WINDOWCOMPAT)
|
---|
| 1048 | ulAppType = SSF_TYPE_WINDOWABLEVIO;
|
---|
| 1049 | else if (ulAppType == FAPPTYP_NOTWINDOWCOMPAT) {
|
---|
| 1050 | type &= ~WINDOWED;
|
---|
| 1051 | ulAppType = SSF_TYPE_FULLSCREEN;
|
---|
| 1052 | }
|
---|
| 1053 | else
|
---|
| 1054 | ulAppType = SSF_TYPE_DEFAULT;
|
---|
| 1055 | if ((type & FULLSCREEN || ~type & WINDOWED) &&
|
---|
| 1056 | ulAppType == SSF_TYPE_WINDOWABLEVIO)
|
---|
| 1057 | {
|
---|
| 1058 | ulAppType = SSF_TYPE_FULLSCREEN;
|
---|
| 1059 | }
|
---|
| 1060 | // fixme parens?
|
---|
| 1061 | else if (type & FULLSCREEN ||
|
---|
| 1062 | (type & WINDOWED && ulAppType == SSF_TYPE_WINDOWEDVDM))
|
---|
| 1063 | {
|
---|
| 1064 | ulAppType = SSF_TYPE_VDM;
|
---|
| 1065 | }
|
---|
[105] | 1066 | }
|
---|
[562] | 1067 | if (ulAppType == SSF_TYPE_WINDOWEDVDM && type & SEPARATEKEEP) {
|
---|
[1394] | 1068 | type &= ~SEPARATEKEEP;
|
---|
| 1069 | type |= SEPARATE;
|
---|
[105] | 1070 | }
|
---|
[2] | 1071 |
|
---|
[519] | 1072 | DosGetInfoBlocks(&ptib, &ppib);
|
---|
| 1073 |
|
---|
[540] | 1074 | if (~type & WAIT)
|
---|
[1394] | 1075 | useTermQ = FALSE;
|
---|
[519] | 1076 | else {
|
---|
[1394] | 1077 | rc = 0;
|
---|
| 1078 | DosEnterCritSec();
|
---|
| 1079 | if (!hTermQ) {
|
---|
| 1080 | // Create term queue and event semaphore just once
|
---|
| 1081 | sprintf(szTermQName, TERMQ_BASE_NAME "_%x", ppib->pib_ulpid);
|
---|
| 1082 | rc = DosCreateQueue(&hTermQ, QUE_FIFO | QUE_CONVERT_ADDRESS, szTermQName);
|
---|
| 1083 | if (rc) {
|
---|
| 1084 | hTermQ = (HQUEUE)0; // Try to survive
|
---|
| 1085 | DosExitCritSec();
|
---|
| 1086 | Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,"DosCreateQueue");
|
---|
| 1087 | }
|
---|
| 1088 | else {
|
---|
| 1089 | rc = DosCreateEventSem(NULL,(PHEV)&hTermQSem,0,FALSE);
|
---|
| 1090 | if (rc) {
|
---|
| 1091 | hTermQSem = (HEV)0; // Try to survive
|
---|
| 1092 | DosCloseQueue(hTermQ);
|
---|
| 1093 | hTermQ = (HQUEUE)0; // Try to survive
|
---|
| 1094 | DosExitCritSec();
|
---|
| 1095 | Dos_Error(MB_ENTER,rc,HWND_DESKTOP,pszSrcFile,__LINE__,"DoCreateEventSem");
|
---|
| 1096 | }
|
---|
| 1097 | // if (!rc) fprintf(stderr,"%s %d qcreated ptib %x hTermQ %x\n",__FILE__, __LINE__,ptib,hTermQ);
|
---|
| 1098 | }
|
---|
| 1099 | } // if 1st time
|
---|
| 1100 | useTermQ = hTermQ && hTermQSem;
|
---|
| 1101 | if (!rc)
|
---|
| 1102 | DosExitCritSec();
|
---|
[540] | 1103 | } // if wait
|
---|
[562] | 1104 |
|
---|
| 1105 | memset(&sdata,0,sizeof(sdata));
|
---|
[519] | 1106 | sdata.Length = sizeof(sdata);
|
---|
[562] | 1107 | sdata.Related = type & (WAIT | CHILD) ? SSF_RELATED_CHILD :
|
---|
[1394] | 1108 | SSF_RELATED_INDEPENDENT;
|
---|
[519] | 1109 | sdata.FgBg = type & BACKGROUND ? SSF_FGBG_BACK : SSF_FGBG_FORE;
|
---|
| 1110 | sdata.TraceOpt = SSF_TRACEOPT_NONE;
|
---|
[540] | 1111 | sdata.PgmName = pszPgm;
|
---|
[562] | 1112 | if (*pszArgs)
|
---|
[1394] | 1113 | sdata.PgmInputs = (PBYTE)pszArgs;
|
---|
[562] | 1114 | if (useTermQ)
|
---|
[1394] | 1115 | sdata.TermQ = (PBYTE)szTermQName;
|
---|
[1321] | 1116 | sdata.Environment = (PBYTE)pszEnvironment;
|
---|
[519] | 1117 | sdata.InheritOpt = SSF_INHERTOPT_PARENT;
|
---|
[562] | 1118 | sdata.SessionType = ulAppType;
|
---|
[540] | 1119 | sdata.ObjectBuffer = szObject;
|
---|
| 1120 | sdata.ObjectBuffLen = sizeof(szObject);
|
---|
[773] | 1121 | if ((type & RUNTYPE_MASK) == SEPARATEKEEP)
|
---|
[1394] | 1122 | sdata.PgmControl |= SSF_CONTROL_NOAUTOCLOSE;
|
---|
[562] | 1123 | if (type & MAXIMIZED)
|
---|
[1394] | 1124 | sdata.PgmControl |= SSF_CONTROL_MAXIMIZE;
|
---|
[562] | 1125 | if (type & MINIMIZED)
|
---|
[1394] | 1126 | sdata.PgmControl |= SSF_CONTROL_MINIMIZE;
|
---|
[562] | 1127 | if (type & INVISIBLE)
|
---|
[1394] | 1128 | sdata.PgmControl |= SSF_CONTROL_INVISIBLE;
|
---|
[562] | 1129 |
|
---|
[540] | 1130 | if (pszDirectory && *pszDirectory) {
|
---|
[1394] | 1131 | strcpy(szSavedir, pFM2SaveDirectory);
|
---|
| 1132 | switch_to(pszDirectory);
|
---|
[105] | 1133 | }
|
---|
[519] | 1134 | ret = DosStartSession(&sdata, &ulSessID, &sessPID);
|
---|
[562] | 1135 |
|
---|
[563] | 1136 |
|
---|
[540] | 1137 | if (pszDirectory && *pszDirectory)
|
---|
[1394] | 1138 | switch_to(szSavedir);
|
---|
[562] | 1139 |
|
---|
[330] | 1140 | if (ret && ret != ERROR_SMG_START_IN_BACKGROUND) {
|
---|
[1394] | 1141 | if (!fNoErrorMsg)
|
---|
| 1142 | Dos_Error(MB_CANCEL,ret,hwnd,pszSrcFile,__LINE__,
|
---|
| 1143 | GetPString(IDS_DOSSTARTSESSIONFAILEDTEXT),pszPgm,pszArgs,
|
---|
| 1144 | pszCallingFile, uiLineNumber); // 26 May 08 SHL
|
---|
[330] | 1145 | }
|
---|
[441] | 1146 | else if (type & WAIT) {
|
---|
[1394] | 1147 | if (!(type & (BACKGROUND | MINIMIZED | INVISIBLE)))
|
---|
| 1148 | ShowSession(hwnd, sessPID);
|
---|
[2] | 1149 |
|
---|
[1394] | 1150 | if (!useTermQ) {
|
---|
| 1151 | STATUSDATA sd;
|
---|
[2] | 1152 |
|
---|
[1394] | 1153 | memset(&sd, 0, sizeof(sd));
|
---|
| 1154 | sd.Length = (USHORT) sizeof(sd);
|
---|
| 1155 | sd.SelectInd = SET_SESSION_UNCHANGED;
|
---|
| 1156 | sd.BondInd = SET_SESSION_UNCHANGED;
|
---|
| 1157 | for (ctr = 0;; ctr++)
|
---|
| 1158 | {
|
---|
| 1159 | DosSleep(100);//05 Aug 07 GKY 200
|
---|
| 1160 | if (DosSetSession(ulSessID, &sd)) // Check if session gone (i.e. finished)
|
---|
| 1161 | break;
|
---|
| 1162 | if (ctr > 10) {
|
---|
| 1163 | ShowSession(hwnd, sessPID); // Show every 2 seconds
|
---|
| 1164 | ctr = 0;
|
---|
| 1165 | }
|
---|
| 1166 | }
|
---|
| 1167 | }
|
---|
| 1168 | else {
|
---|
| 1169 | for (ctr = 0;; ctr++)
|
---|
| 1170 | {
|
---|
| 1171 | if (ctr < 20) {
|
---|
| 1172 | rc = DosReadQueue(hTermQ, &rq, &ulLength, (PPVOID)&pTermInfo, 0,
|
---|
| 1173 | DCWW_NOWAIT, &bPriority, hTermQSem);
|
---|
| 1174 | if (rc == ERROR_QUE_EMPTY) {
|
---|
| 1175 | DosSleep(50);//05 Aug 07 GKY 100
|
---|
| 1176 | continue;
|
---|
| 1177 | }
|
---|
| 1178 | }
|
---|
| 1179 | else {
|
---|
| 1180 | if (ctr == 20) {
|
---|
| 1181 | ShowSession(hwnd, sessPID); // Show long running session
|
---|
| 1182 | }
|
---|
| 1183 | rc = DosReadQueue(hTermQ, &rq, &ulLength, (PPVOID)&pTermInfo, 0,
|
---|
| 1184 | DCWW_WAIT, &bPriority, 0);
|
---|
| 1185 | }
|
---|
[540] | 1186 |
|
---|
[1394] | 1187 | if (rc) {
|
---|
| 1188 | // Oh heck
|
---|
| 1189 | Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,"DosReadQueue");
|
---|
| 1190 | DosSleep(100);//05 Aug 07 GKY 500
|
---|
| 1191 | continue;
|
---|
| 1192 | }
|
---|
[540] | 1193 |
|
---|
[1394] | 1194 | // printf("%s %d DosReadQueue thread 0x%x sess %u sessRC %u rq.pid 0x%x rq.data 0x%x\n",
|
---|
| 1195 | // __FILE__, __LINE__,ptib->tib_ordinal,pTermInfo->usSessID,pTermInfo->usRC,rq.pid, rq.ulData); fflush(stdout);
|
---|
[562] | 1196 |
|
---|
[1394] | 1197 | if (pTermInfo->usSessID == ulSessID)
|
---|
| 1198 | break; // Our session is done
|
---|
[540] | 1199 |
|
---|
[1394] | 1200 | // Requeue session for other thread
|
---|
| 1201 | {
|
---|
| 1202 | static ULONG ulLastSessID;
|
---|
| 1203 | // printf("%s %d requeue thread 0x%x our sess %u term sess %u term rc %u\n",
|
---|
| 1204 | // __FILE__, __LINE__,ptib->tib_ordinal,ulSessID,pTermInfo->usSessID,pTermInfo->usRC); fflush(stdout);
|
---|
| 1205 | // fixme to be gone when no longer needed for debug?
|
---|
| 1206 | if (ulLastSessID) {
|
---|
| 1207 | DosSleep(100);//05 Aug 07 GKY 500
|
---|
| 1208 | ulLastSessID = pTermInfo->usSessID;
|
---|
| 1209 | }
|
---|
| 1210 | // requeue term report for other thread and do not free yet
|
---|
| 1211 | rc = DosWriteQueue(hTermQ, rq.ulData, ulLength,(PVOID)pTermInfo, bPriority);
|
---|
| 1212 | if (rc)
|
---|
| 1213 | Dos_Error(MB_CANCEL,rc,hwnd,pszSrcFile,__LINE__,"DosWriteQueue");
|
---|
| 1214 | DosSleep(50); //05 Aug 07 GKY 100 // Let other thread see queue entry
|
---|
| 1215 | }
|
---|
| 1216 | } // for
|
---|
[540] | 1217 |
|
---|
[1394] | 1218 | ret = pTermInfo->usRC == 0; // Set 1 if rc 0 else 0
|
---|
| 1219 | // printf("%s %d thread 0x%x term for sess %u\n",
|
---|
| 1220 | // __FILE__, __LINE__,ptib->tib_ordinal,ulSessID);fflush(stdout);
|
---|
| 1221 | DosFreeMem(pTermInfo);
|
---|
| 1222 | }
|
---|
[540] | 1223 | } // if wait
|
---|
[105] | 1224 | else if (!(type & (BACKGROUND | MINIMIZED | INVISIBLE)))
|
---|
[1394] | 1225 | ShowSession(hwnd, sessPID);
|
---|
[105] | 1226 | }
|
---|
| 1227 | }
|
---|
[2] | 1228 |
|
---|
| 1229 | ObjectInterrupt:
|
---|
| 1230 |
|
---|
[540] | 1231 | if (pszPgm)
|
---|
| 1232 | DosFreeMem(pszPgm);
|
---|
| 1233 | if (pszArgs)
|
---|
| 1234 | DosFreeMem(pszArgs);
|
---|
[562] | 1235 |
|
---|
[105] | 1236 | return ret;
|
---|
[2] | 1237 | }
|
---|
| 1238 |
|
---|
[519] | 1239 | //== Exec() Start application with WinStartApp ==
|
---|
[1193] | 1240 | #if 0 // JBS 11 Sep 08
|
---|
[105] | 1241 | HAPP Exec(HWND hwndNotify, BOOL child, char *startdir, char *env,
|
---|
[1394] | 1242 | PROGTYPE *progt, ULONG fl, char *formatstring,...)
|
---|
[78] | 1243 | {
|
---|
[105] | 1244 | PROGDETAILS pgd;
|
---|
[2] | 1245 | register char *p;
|
---|
[105] | 1246 | char *parameters = NULL, *executable = NULL;
|
---|
[519] | 1247 | HAPP happ = (HAPP)0;
|
---|
[105] | 1248 | ULONG ulOptions = SAF_INSTALLEDCMDLINE;
|
---|
| 1249 | BOOL wasquote;
|
---|
| 1250 | va_list parguments;
|
---|
[2] | 1251 |
|
---|
[105] | 1252 | if (child)
|
---|
[2] | 1253 | ulOptions |= SAF_STARTCHILDAPP;
|
---|
| 1254 |
|
---|
[985] | 1255 | executable = xmallocz(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
[330] | 1256 | if (executable) {
|
---|
[105] | 1257 | va_start(parguments, formatstring);
|
---|
| 1258 | vsprintf(executable, formatstring, parguments);
|
---|
[2] | 1259 | va_end(parguments);
|
---|
[105] | 1260 | strip_lead_char(" \t", executable);
|
---|
[441] | 1261 | if (*executable) {
|
---|
[985] | 1262 | parameters = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
[441] | 1263 | if (parameters) {
|
---|
[1394] | 1264 | p = executable;
|
---|
| 1265 | wasquote = FALSE;
|
---|
| 1266 | while (*p && (wasquote || (*p != ' ' && *p != '\t'))) {
|
---|
| 1267 | if (*p == '\"') {
|
---|
| 1268 | if (!wasquote) {
|
---|
| 1269 | wasquote = TRUE;
|
---|
| 1270 | memmove(p, p + 1, strlen(p));
|
---|
| 1271 | while (*p == ' ' || *p == '\t')
|
---|
| 1272 | p++;
|
---|
| 1273 | }
|
---|
| 1274 | else {
|
---|
| 1275 | memmove(p, p + 1, strlen(p));
|
---|
| 1276 | break;
|
---|
| 1277 | }
|
---|
| 1278 | }
|
---|
| 1279 | else
|
---|
| 1280 | p++;
|
---|
| 1281 | }
|
---|
| 1282 | if (*p) {
|
---|
| 1283 | *p = 0;
|
---|
| 1284 | p++;
|
---|
| 1285 | }
|
---|
| 1286 | else
|
---|
| 1287 | p = NullStr;
|
---|
| 1288 | if (*p)
|
---|
| 1289 | strcpy(parameters, p);
|
---|
[2] | 1290 |
|
---|
[1398] | 1291 | if (p && (!stricmp(p, PCSZ_DOTBAT) || !stricmp(p, PCSZ_DOTCMD) ||
|
---|
| 1292 | !stricmp(p, PCSZ_DOTBTM))) {
|
---|
[1394] | 1293 | char *temp;
|
---|
[2] | 1294 |
|
---|
[1394] | 1295 | temp = xmalloc(CCHMAXPATH * 2,pszSrcFile,__LINE__);
|
---|
| 1296 | if (temp) {
|
---|
[1398] | 1297 | if (!stricmp(p, PCSZ_DOTBAT)) {
|
---|
| 1298 | if (!fProtectOnly) {
|
---|
| 1299 | strcpy(temp, executable);
|
---|
| 1300 | strcpy(executable, parameters);
|
---|
| 1301 | strcpy(parameters, "/C ");
|
---|
| 1302 | strcat(parameters, temp);
|
---|
| 1303 | strcat(parameters, " ");
|
---|
| 1304 | strcat(parameters, executable);
|
---|
| 1305 | strcpy(executable, GetCmdSpec(TRUE));
|
---|
| 1306 | }
|
---|
| 1307 | else
|
---|
| 1308 | saymsg(MB_OK,
|
---|
| 1309 | HWND_DESKTOP,
|
---|
| 1310 | NullStr,
|
---|
| 1311 | GetPString(IDS_NOTPROTECTONLYEXE),
|
---|
| 1312 | filename);
|
---|
[1394] | 1313 | }
|
---|
[1398] | 1314 | else if (!stricmp(p, PCSZ_DOTCMD) || !stricmp(p, PCSZ_DOTBTM)) {
|
---|
[1394] | 1315 | strcpy(temp, executable);
|
---|
| 1316 | strcpy(executable, parameters);
|
---|
| 1317 | strcpy(parameters, "/C ");
|
---|
| 1318 | strcat(parameters, temp);
|
---|
| 1319 | strcat(parameters, " ");
|
---|
| 1320 | strcat(parameters, executable);
|
---|
| 1321 | strcpy(executable, GetCmdSpec(FALSE));
|
---|
| 1322 | }
|
---|
| 1323 | free(temp);
|
---|
| 1324 | }
|
---|
| 1325 | }
|
---|
[2] | 1326 |
|
---|
[1394] | 1327 | memset(&pgd, 0, sizeof(pgd));
|
---|
| 1328 | pgd.Length = sizeof(pgd);
|
---|
| 1329 | pgd.progt = *progt;
|
---|
| 1330 | pgd.swpInitial.fl = fl;
|
---|
| 1331 | pgd.pszEnvironment = env;
|
---|
| 1332 | pgd.pszStartupDir = startdir;
|
---|
| 1333 | pgd.pszParameters = *parameters ? parameters : NULL;
|
---|
| 1334 | pgd.pszExecutable = executable;
|
---|
| 1335 | pgd.swpInitial.hwndInsertBehind = HWND_TOP;
|
---|
| 1336 | happ = WinStartApp(hwndNotify, &pgd, NULL, NULL, ulOptions);
|
---|
| 1337 | free(parameters);
|
---|
[2] | 1338 | }
|
---|
| 1339 | }
|
---|
[1039] | 1340 | free(executable);
|
---|
[2] | 1341 | }
|
---|
| 1342 | return happ;
|
---|
| 1343 | }
|
---|
[1162] | 1344 | #endif
|
---|
[920] | 1345 | #pragma alloc_text(SYSTEMF,ShowSession,ExecOnList,runemf2)
|
---|