Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1731 lines
45 KiB

  1. #include "precomp.h"
  2. #pragma hdrstop
  3. /***************************************************************************
  4. MODULE: DOSPIF.c
  5. This file contains procedures that create Program Information Files
  6. (PIFs) for DOS apps using information contained in the APPS.INF file.
  7. Copyright (C) Microsoft, 1991
  8. HISTORY:
  9. Modified by: Date: Comment:
  10. PAK 11/2/90 Created
  11. PAK 8/18/91 Major Clean-up, rewrite, and bug fixes.
  12. SUNILP 2/04/92 Changed for Win 32 GUI Setup use
  13. DESCRIPTION:
  14. ***************************************************************************/
  15. extern HWND hwndFrame;
  16. //
  17. // This is common between dospif and search, so should go in an include file
  18. //
  19. #define EXE_WIN16_SZ "WIN16"
  20. #define EXE_WIN32_SZ "WIN32"
  21. #define EXE_DOS_SZ "DOS"
  22. /* Globals (App Modules) */
  23. CB cbAllPIF = 0;
  24. LPVOID lpAllPIF = NULL;
  25. static SZ szDOTPIF = ".PIF";
  26. static SZ szProgman = "PROGMAN.EXE";
  27. /* Globals (This Module) */
  28. static BOOL bNoTrpHRGrfx = fTrue;
  29. static BOOL bIs386 = fTrue;
  30. /* statics which are global to this module. */
  31. static LPPIFNEWSTRUCT lpDfltPIF = NULL;
  32. static LPPIFNEWSTRUCT lpCurrPIF = NULL;
  33. static LPPIFEXTHEADER lpStdExtHdr = NULL;
  34. static LPPIF286EXT30 lpDfltStd = NULL;
  35. static LPPIF286EXT30 lpCurrStd = NULL;
  36. static LPPIFEXTHEADER lpEnhaExtHdr = NULL;
  37. static LPPIF386EXT lpDfltEnha = NULL;
  38. static LPPIF386EXT lpCurrEnha = NULL;
  39. /***************************************************************************
  40. AddWinItem
  41. ----------
  42. DESCRIPTION:
  43. This processes an Win16 | Win 32 App item in the App List. The app rgsz
  44. structure is documented below:
  45. rgszApp[nEXETYPE= 0] : WIN16 | WIN32
  46. rgszApp[nNAME = 1] : App Name
  47. rgszApp[nEXE = 2] : App Exe (full path to the exe)
  48. HISTORY:
  49. Modified by: Date: Comment:
  50. PAK 11/2/90 Created
  51. PAK 3/22/91 GenerateProgmanPath is no longer called
  52. since the PIFs all go in the same directory
  53. and will always be found.
  54. SUNILP 2/5/92 Modified extensively for GUI Setup toolkit
  55. ***************************************************************************/
  56. ADDAPP_STATUS
  57. AddWinItem(
  58. IN RGSZ rgszApp,
  59. IN SZ szGroup
  60. )
  61. {
  62. ADDAPP_STATUS Status = ADDAPP_SUCCESS;
  63. SZ szIconFile = "";
  64. INT nIcon = 0; /* default icon */
  65. CMO cmo = cmoVital;
  66. BOOL bStatus;
  67. bStatus = FCreateProgManItem(
  68. szGroup, // Group to add
  69. rgszApp[nNAME], // Item name
  70. rgszApp[nEXE], // Command field
  71. szIconFile, // Icon file
  72. nIcon, // Icon number
  73. cmo, // vital?
  74. TRUE // common group
  75. );
  76. if (!bStatus) {
  77. Status = ADDAPP_GRPFAIL;
  78. }
  79. return (Status);
  80. }
  81. /***************************************************************************
  82. AddDosAppItem
  83. --------------
  84. DESCRIPTION:
  85. This processes a DOS App item in the App List. The app rgsz structure
  86. is documented below:
  87. rgszApp[nEXETYPE= 0] : DOS
  88. rgszApp[nNAME = 1] : App Name
  89. rgszApp[nEXE = 2] : App Exe (full path to the exe)
  90. rgszApp[nDIR = 3] : App Directory
  91. rgszApp[nPIF = 4] : App PIF Name
  92. rgszApp[nDEFDIR = 5] : App Default Directory ("" means user App Direct)
  93. rgszApp[nCWE = 6] : App CWE field ("" means no, "cwe" means close)
  94. rgszApp[nSTDOPT = 7] : App Standard mode options ({} for no section)
  95. rgszApp[nENHOPT = 8] : App Enhanced mode options ({} for no section)
  96. rgszApp[nICOFIL = 9] : App Icon File ("" means use default)
  97. rgszApp[nICONUM = 10] : App Icon Num ("" means use default)
  98. HISTORY:
  99. Modified by: Date: Comment:
  100. PAK 11/2/90 Created
  101. PAK 3/22/91 GenerateProgmanPath is no longer called
  102. since the PIFs all go in the same directory
  103. and will always be found.
  104. SUNILP 2/5/92 Modified extensively for GUI Setup toolkit
  105. ***************************************************************************/
  106. ADDAPP_STATUS
  107. AddDosAppItem(
  108. IN RGSZ rgszApp,
  109. IN SZ szPifDir,
  110. IN SZ szGroup
  111. )
  112. {
  113. ADDAPP_STATUS Status = ADDAPP_GENFAIL;
  114. CHP szPIFPath[cchlFullPathBuf];
  115. SZ szIconFile = rgszApp[nICOFIL];
  116. INT nIcon = 0; /* default icon */
  117. CMO cmo = cmoVital;
  118. BOOL bStatus;
  119. // Build the PIF file.
  120. if ( FDeterminePIFName(rgszApp, szPifDir, szPIFPath) &&
  121. FCreatePIF(rgszApp, szPIFPath)
  122. ) {
  123. //
  124. // Check IconFile
  125. //
  126. if (CrcStringCompareI(szIconFile, "") == crcEqual) {
  127. szIconFile = szProgman;
  128. }
  129. //
  130. // Check icon number
  131. //
  132. if (CrcStringCompareI(rgszApp[nICONUM], "") != crcEqual) {
  133. nIcon = atoi(rgszApp[nICONUM]);
  134. }
  135. bStatus = FCreateProgManItem(
  136. szGroup, // Group to add
  137. rgszApp[nNAME], // Item name
  138. szPIFPath, // Command field
  139. szIconFile, // Icon file
  140. nIcon, // Icon number
  141. cmo, // vital?
  142. TRUE // common group
  143. );
  144. if (bStatus) {
  145. Status = ADDAPP_SUCCESS;
  146. }
  147. else {
  148. Status = ADDAPP_GRPFAIL;
  149. }
  150. }
  151. return (Status);
  152. }
  153. /***************************************************************************
  154. DeterminePIFName
  155. ----------------
  156. DESCRIPTION:
  157. This procedure will determine a name (possibly with user interaction)
  158. for the PIF which is to be created. If the proposed PIF name already
  159. exists and the user does not wish to replace it, an alternative name
  160. will be sought. The alternative name is obtained by adding 2 digits
  161. to the end of the file name (if possible) and assertaining whether the
  162. new PIF exists. If the filename is already seven or eight characters
  163. in length the last two characters are replaced with digits.
  164. E.G. filename.PIF becomes filena00.PIF
  165. file.PIF becomes file00.PIF
  166. The last two digits of the filename are incremented to 99 until a
  167. non-existant file is found.
  168. The user will be asked to replace the PIF if we determine that the PIF
  169. we are about to create is for the same EXE name and contains the same
  170. description string in the prexisting PIF.
  171. HISTORY:
  172. Modified by: Date: Comment:
  173. PAK 7/31/91 Created
  174. SUNILP 2/6/92 Removed questioning user for alternate PIF
  175. Changed to use Setup file functions.
  176. ***************************************************************************/
  177. BOOL
  178. FDeterminePIFName(
  179. IN RGSZ rgszApp,
  180. IN SZ szPifDir,
  181. IN OUT SZ szPIFPath
  182. )
  183. {
  184. PFH pfh;
  185. SZ szName[PIFNAMESIZE+1];
  186. SZ szExe[PIFSTARTLOCSIZE+1];
  187. int i = 0, iLen;
  188. char sub_char1 = '0';
  189. char sub_char2 = '0';
  190. BOOL bConcat, bInitialConcat = fTrue;
  191. BOOL bCouldntDelete = fFalse, bCouldntRead = fFalse;
  192. // We need to find out if the proposed pif already exists
  193. // If it does we need to open it for reading and extract
  194. // the name and description fields to make sure that the
  195. // PIF is for the same app.
  196. //
  197. //
  198. // Build the fully qualified Pif file
  199. //
  200. lstrcpy(szPIFPath, szPifDir);
  201. lstrcat(szPIFPath, rgszApp[nPIF]);
  202. lstrcat(szPIFPath, szDOTPIF);
  203. //
  204. // Does the PIF already exist, if yes open for reading. if no then
  205. // return because we already have the PIF Path we need.
  206. //
  207. if ((pfh = PfhOpenFile(szPIFPath, ofmRead)) == (PFH)NULL) {
  208. return (fTrue);
  209. }
  210. // The Proposed PIF already exists
  211. // Can we extract the Description and Exe Name?
  212. // If NO, create new PIF since if we cant read it we probably won't
  213. // be able to replace it.
  214. //
  215. if ( (LfaSeekFile(pfh, 2L, sfmSet) != 2L) ||
  216. (CbReadFile(pfh, (PB)szName, (CB)PIFNAMESIZE) != PIFNAMESIZE) ||
  217. (LfaSeekFile(pfh, 4L, sfmCur) != (CB)PIFNAMESIZE + 2L + 4L) ||
  218. (CbReadFile(pfh, (PB)szExe, (CB)PIFSTARTLOCSIZE) != PIFSTARTLOCSIZE)
  219. ) {
  220. bCouldntRead = fTrue;
  221. }
  222. // Close Preexisting PIF as we no longer require info from it
  223. FCloseFile(pfh);
  224. pfh = (PFH)NULL;
  225. if (!bCouldntRead) {
  226. ExtractStrFromPIF((LPSTR)szName, PIFNAMESIZE);
  227. if (!lstrcmpi((LPSTR)szExe, rgszApp[nEXE]) &&
  228. !lstrcmpi((LPSTR)szName, rgszApp[nNAME])
  229. ) {
  230. // No asking the user, just delete.
  231. if (FRemoveFile(szPIFPath)) {
  232. return (fTrue);
  233. }
  234. }
  235. }
  236. /* see if PIF specified in szPIFPath already exists. If it does
  237. we change the name, looking for a name that doesn't exist.
  238. */
  239. if (lstrlen(szGetFileName(szPIFPath)) < 11) {
  240. bConcat = fTrue;
  241. }
  242. else {
  243. bConcat = fFalse;
  244. }
  245. iLen = lstrlen(szPIFPath);
  246. i = 0;
  247. while (FFileExists(szPIFPath))
  248. {
  249. if (i == 100) {
  250. return fFalse;
  251. }
  252. if (bConcat)
  253. {
  254. if (bInitialConcat)
  255. {
  256. bInitialConcat = fFalse;
  257. szPIFPath[iLen-2] = '.';
  258. szPIFPath[iLen-1] = 'P';
  259. szPIFPath[iLen] = 'I';
  260. szPIFPath[iLen+1] = 'F';
  261. szPIFPath[iLen+2] = '\0';
  262. }
  263. szPIFPath[iLen-4] = sub_char1;
  264. szPIFPath[iLen-3] = sub_char2;
  265. }
  266. else
  267. {
  268. szPIFPath[iLen-6] = sub_char1;
  269. szPIFPath[iLen-5] = sub_char2;
  270. }
  271. if (sub_char2 == '9')
  272. {
  273. sub_char1++;
  274. sub_char2 = '0';
  275. }
  276. else
  277. sub_char2++;
  278. i++;
  279. }
  280. return( fTrue );
  281. }
  282. /***************************************************************************
  283. FCreatePIF
  284. ----------
  285. DESCRIPTION:
  286. This code creates the PIF file.
  287. For the 286 product only the 286 PIF extensions are added.
  288. For the 386 product both 286 and the 386 extension are added.
  289. The PIF file looks like this
  290. PIFNEWSTRUCT +---------------+
  291. | |
  292. | |
  293. | |
  294. | PIFEXTHEADER |
  295. +---------------+
  296. PIFEXTHEADER +---------------+
  297. | for Standard |
  298. | |
  299. +---------------+
  300. PIF286EXT30 +---------------+
  301. | |
  302. | |
  303. +---------------+
  304. PIFEXTHEADER +---------------+ this only present for 386 product
  305. | for Enhanced | |
  306. | | v
  307. +---------------+
  308. PIF386EXT +---------------+
  309. | |
  310. | |
  311. +---------------+
  312. HISTORY:
  313. Modified by: Date: Comment:
  314. PAK 11/2/90 Created
  315. SUNILP 2/5/92 Modified to use Setup File functions.
  316. ***************************************************************************/
  317. BOOL
  318. FCreatePIF(
  319. RGSZ rgszApp,
  320. SZ szPIFPath
  321. )
  322. {
  323. PFH pfh = (PFH)NULL;
  324. CB cbActual;
  325. BOOL bStatus;
  326. PACKED_PIFNEWSTRUCT PPif;
  327. // Create PIF, at this point it does not exist
  328. if (!(pfh = PfhOpenFile(szPIFPath, ofmCreate))) {
  329. return (fFalse);
  330. }
  331. // Copy Default PIF to current PIF
  332. memmove((PVOID)lpCurrPIF, (PVOID)lpDfltPIF, sizeof(PIFNEWSTRUCT));
  333. memmove((PVOID)lpCurrStd, (PVOID)lpDfltStd, sizeof(PIF286EXT30));
  334. if (bIs386) {
  335. memmove((PVOID)lpCurrEnha, (PVOID)lpDfltEnha, sizeof(PIF386EXT));
  336. }
  337. // Process information common to both standard and enhanced mode PIFs
  338. ProcessCommonInfo( rgszApp, lpCurrPIF );
  339. // Write information particular to standard mode PIFs to Current PIF
  340. bStatus = FProcessStdModeInfo(rgszApp[nSTDOPT], lpCurrPIF, lpCurrStd);
  341. if (!bStatus) {
  342. return (fFalse);
  343. }
  344. //
  345. // write PIF struct, and 286 extension header and extension.
  346. //
  347. PackPif(lpCurrPIF, &PPif);
  348. cbActual = sizeof(PACKED_PIFNEWSTRUCT);
  349. if (cbActual != CbWriteFile(pfh, (PB)&PPif, (CB)cbActual)) {
  350. return (fFalse);
  351. }
  352. cbActual = sizeof(PIFEXTHEADER);
  353. if (cbActual != CbWriteFile(pfh, (PB)lpStdExtHdr, (CB)cbActual)) {
  354. return (fFalse);
  355. }
  356. cbActual = sizeof(PIF286EXT30);
  357. if (cbActual != CbWriteFile(pfh, (PB)lpCurrStd, (CB)cbActual)) {
  358. return (fFalse);
  359. }
  360. //
  361. // Write information particular to enhanced mode PIFs to Current PIF
  362. //
  363. if (bIs386) {
  364. bStatus = FProcessEnhaModeInfo( rgszApp[nENHOPT], lpCurrEnha);
  365. if (!bStatus) {
  366. return (fFalse);
  367. }
  368. cbActual = sizeof(PIFEXTHEADER);
  369. if (cbActual != CbWriteFile(pfh, (PB)lpEnhaExtHdr, (CB)cbActual)) {
  370. return (fFalse);
  371. }
  372. cbActual = sizeof(PIF386EXT);
  373. if (cbActual != CbWriteFile(pfh, (PB)lpCurrEnha, (CB)cbActual)) {
  374. return (fFalse);
  375. }
  376. }
  377. bStatus = FCloseFile(pfh);
  378. return (bStatus);
  379. }
  380. /***************************************************************************
  381. ProcessCommonInfo
  382. ------------------
  383. DESCRIPTION:
  384. This procedure will set the Common PIF settings.
  385. HISTORY:
  386. Modified by: Date: Comment:
  387. SUNILP 2/4/92 Changed to use INF Vars from symbol table
  388. ***************************************************************************/
  389. VOID
  390. ProcessCommonInfo(
  391. RGSZ rgszApp,
  392. LPPIFNEWSTRUCT lpPNS
  393. )
  394. {
  395. // Write information common to both standard and enhanced mode PIFs
  396. // to Current PIF
  397. // 1. App Filename
  398. lstrcpy( lpPNS->startfile, rgszApp[nEXE] );
  399. // 2. App Title
  400. lstrcpy( lpPNS->name, rgszApp[nNAME] );
  401. // 3. Default Startup Dir
  402. if (!lstrcmpi(rgszApp[nDEFDIR], "")) {
  403. lstrcpy(lpPNS->defpath, rgszApp[nDIR] );
  404. }
  405. else {
  406. lstrcpy(lpPNS->defpath, rgszApp[nDEFDIR] );
  407. }
  408. if ( (lpPNS->defpath)[lstrlen(lpPNS->defpath) - 1] == '\\' ) {
  409. (lpPNS->defpath)[lstrlen(lpPNS->defpath) - 1] = '\0';
  410. }
  411. // 4. Close Window on exit
  412. if (!lstrcmpi(rgszApp[nCWE], CLOSE_ON_EXIT)) {
  413. lpPNS->MSflags |= EXITMASK;
  414. }
  415. return;
  416. }
  417. /***************************************************************************
  418. FProcessStdModeInfo
  419. -------------------
  420. DESCRIPTION:
  421. This procedure will set the Standard Mode PIF settings according to the
  422. information given in APPS.INF.
  423. HISTORY:
  424. Modified by: Date: Comment:
  425. PAK 11/2/90 Created
  426. SUNILP 2/4/92 Changed to use INF Vars from symbol table
  427. ***************************************************************************/
  428. BOOL
  429. FProcessStdModeInfo(
  430. SZ szStdOptions,
  431. LPPIFNEWSTRUCT lpPNS,
  432. LPPIF286EXT30 lpPStd
  433. )
  434. {
  435. PSZ pszStdOptions;
  436. SZ szOption;
  437. RGSZ rgszStdOptions, rgszOption, rgszVal;
  438. int iOption;
  439. //
  440. // szStdOptions: {{Var1, Val1}, {Var2, Val2}, {Var3, Val3}}
  441. //
  442. while ((pszStdOptions = rgszStdOptions = RgszFromSzListValue(szStdOptions)) == (RGSZ)NULL) {
  443. if (!FHandleOOM(hwndFrame)) {
  444. return(fFalse);
  445. }
  446. }
  447. //
  448. // For all options found
  449. //
  450. while ((szOption = *pszStdOptions++) != NULL) {
  451. //
  452. // Find the Var, Val pair
  453. //
  454. while ((rgszOption = RgszFromSzListValue(szOption)) == (RGSZ)NULL) {
  455. if (!FHandleOOM(hwndFrame)) {
  456. EvalAssert(FFreeRgsz(rgszStdOptions));
  457. return(fFalse);
  458. }
  459. }
  460. //
  461. // Check validity of option
  462. //
  463. if (rgszOption[0] == NULL || rgszOption[1] == NULL) {
  464. EvalAssert(FFreeRgsz(rgszOption));
  465. continue;
  466. }
  467. //
  468. // Examine Option Variable
  469. //
  470. iOption = GetExtOption(rgszOption[0]);
  471. switch (iOption) {
  472. case PARAMS:
  473. lstrcpy(lpPNS->params, rgszOption[1]);
  474. break;
  475. case MINCONVMEM:
  476. if (!lstrcmp(rgszOption[1], "-1")) {
  477. lpPNS->minmem = 0xFFFF;
  478. }
  479. else {
  480. lpPNS->minmem = (WORD)atoi(rgszOption[1]);
  481. }
  482. break;
  483. case VIDEOMODE:
  484. if (!lstrcmpi(rgszOption[1], TEXT_OPT))
  485. {
  486. lpPNS->MSflags &= TEXTMASK;
  487. lpPNS->sysmem = 7;
  488. }
  489. else if (!lstrcmpi(rgszOption[1], GRAF_MULTXT))
  490. {
  491. lpPNS->MSflags |= GRAPHMASK;
  492. lpPNS->sysmem = 23;
  493. }
  494. break;
  495. case XMSMEM:
  496. while ((rgszVal = RgszFromSzListValue(rgszOption[1])) == (RGSZ)NULL) {
  497. if (!FHandleOOM(hwndFrame)) {
  498. EvalAssert(FFreeRgsz(rgszOption));
  499. EvalAssert(FFreeRgsz(rgszStdOptions));
  500. return (fFalse);
  501. }
  502. }
  503. if (rgszVal[0] == NULL || rgszVal[1] == NULL) {
  504. EvalAssert(FFreeRgsz(rgszVal));
  505. break;
  506. }
  507. lpPStd->PfMinXmsK = (WORD)atoi(rgszVal[0]);
  508. if (!lstrcmp(rgszVal[1], "-1")) {
  509. lpPStd->PfMaxXmsK = 0xFFFF;
  510. }
  511. else {
  512. lpPStd->PfMaxXmsK = (WORD)atoi(rgszVal[1]);
  513. }
  514. EvalAssert(FFreeRgsz(rgszVal));
  515. break;
  516. case CHECKBOXES:
  517. while ((rgszVal = RgszFromSzListValue(rgszOption[1])) == (RGSZ)NULL) {
  518. if (!FHandleOOM(hwndFrame)) {
  519. EvalAssert(FFreeRgsz(rgszOption));
  520. EvalAssert(FFreeRgsz(rgszStdOptions));
  521. return (fFalse);
  522. }
  523. }
  524. ProcessCheckBoxSwitches(rgszVal, lpPNS, lpPStd);
  525. EvalAssert(FFreeRgsz(rgszVal));
  526. break;
  527. default:
  528. break;
  529. }
  530. EvalAssert(FFreeRgsz(rgszOption));
  531. }
  532. EvalAssert(FFreeRgsz(rgszStdOptions));
  533. return (fTrue);
  534. }
  535. /***************************************************************************
  536. ProcessCheckBoxSwitches
  537. -----------------------
  538. DESCRIPTION:
  539. This procedure will process the "checkboxes = ..." line from the given
  540. standard PIF section of APPS.INF. The various fields of the line will
  541. affect the pif and pif286 structures.
  542. HISTORY:
  543. Modified by: Date: Comment:
  544. PAK 11/2/90 Created
  545. SUNILP 2/4/92 Modified to use RGSZ list
  546. ***************************************************************************/
  547. VOID
  548. ProcessCheckBoxSwitches(
  549. RGSZ rgsz,
  550. LPPIFNEWSTRUCT lpPNS,
  551. LPPIF286EXT30 lpPStd
  552. )
  553. {
  554. int i;
  555. SZ szStr;
  556. /* If this gets called we are not using defaults for "checkboxes"
  557. so reset all bits that "checkboxes =" can set.
  558. */
  559. lpPNS->MSflags &= ~(PSMASK | SGMASK | COM1MASK | COM2MASK);
  560. lpPNS->behavior &= ~KEYMASK;
  561. lpPStd->PfW286Flags &= ~(fALTTABdis286 | fALTESCdis286 | fALTPRTSCdis286 |
  562. fPRTSCdis286 | fCTRLESCdis286 | fNoSaveVid286 |
  563. fCOM3_286 | fCOM4_286);
  564. i = 0;
  565. while ((szStr = rgsz[i++]) != (SZ)NULL) {
  566. if (!lstrcmpi(szStr, COM1)) {
  567. lpPNS->MSflags |= COM1MASK;
  568. }
  569. else if (!lstrcmpi(szStr, COM2)) {
  570. lpPNS->MSflags |= COM2MASK;
  571. }
  572. else if (!lstrcmpi(szStr, COM3)) {
  573. lpPStd->PfW286Flags |= fCOM3_286;
  574. }
  575. else if (!lstrcmpi(szStr, COM4)) {
  576. lpPStd->PfW286Flags |= fCOM4_286;
  577. }
  578. else if (!lstrcmpi(szStr, NO_SCRN_EXCHANGE)) {
  579. lpPNS->MSflags |= SGMASK;
  580. }
  581. else if (!lstrcmpi(szStr, KEYB)) {
  582. lpPNS->behavior |= KEYMASK;
  583. }
  584. else if (!lstrcmpi(szStr, PREVENT_PROG_SW)) {
  585. lpPNS->MSflags |= PSMASK;
  586. }
  587. else if (!lstrcmpi(szStr, ALT_TAB)) {
  588. lpPStd->PfW286Flags |= fALTTABdis286;
  589. }
  590. else if (!lstrcmpi(szStr, ALT_ESC)) {
  591. lpPStd->PfW286Flags |= fALTESCdis286;
  592. }
  593. else if (!lstrcmpi(szStr, CTRL_ESC)) {
  594. lpPStd->PfW286Flags |= fCTRLESCdis286;
  595. }
  596. else if (!lstrcmpi(szStr, PRSCRN)) {
  597. lpPStd->PfW286Flags |= fPRTSCdis286;
  598. }
  599. else if (!lstrcmpi(szStr, ALT_PRSCRN)) {
  600. lpPStd->PfW286Flags |= fALTPRTSCdis286;
  601. }
  602. else if (!lstrcmpi(szStr, NO_SAVE_SCREEN)) {
  603. lpPStd->PfW286Flags |= fNoSaveVid286;
  604. }
  605. }
  606. }
  607. /***************************************************************************
  608. FProcessEnhaModeInfo
  609. -------------------
  610. DESCRIPTION:
  611. This procedure will set the Standard Mode PIF settings according to the
  612. information given in APPS.INF.
  613. HISTORY:
  614. Modified by: Date: Comment:
  615. PAK 11/2/90 Created
  616. SUNILP 2/4/92 Modified for Win32 GUI Setup.
  617. ***************************************************************************/
  618. BOOL
  619. FProcessEnhaModeInfo(
  620. SZ szEnhOptions,
  621. LPPIF386EXT lpPEnha
  622. )
  623. {
  624. PSZ pszEnhOptions;
  625. SZ szOption, szVal;
  626. RGSZ rgszEnhOptions, rgszOption, rgszVal;
  627. int i, iOption;
  628. //
  629. // szEnhOptions: {{Var1, Val1}, {Var2, Val2}, {Var3, Val3}}
  630. //
  631. while ((pszEnhOptions = rgszEnhOptions = RgszFromSzListValue(szEnhOptions)) == (RGSZ)NULL) {
  632. if (!FHandleOOM(hwndFrame)) {
  633. return (fFalse);
  634. }
  635. }
  636. //
  637. // For all options found
  638. //
  639. while ((szOption = *pszEnhOptions++) != NULL) {
  640. //
  641. // Find the Var, Val pair
  642. //
  643. while ((rgszOption = RgszFromSzListValue(szOption)) == (RGSZ)NULL) {
  644. if (!FHandleOOM(hwndFrame)) {
  645. EvalAssert(FFreeRgsz(rgszEnhOptions));
  646. return (fFalse);
  647. }
  648. }
  649. //
  650. // Check validity of option
  651. //
  652. if (rgszOption[0] == NULL || rgszOption[1] == NULL) {
  653. EvalAssert(FFreeRgsz(rgszOption));
  654. continue;
  655. }
  656. //
  657. // Examine Option Variable
  658. //
  659. iOption = GetExtOption(rgszOption[0]);
  660. switch (iOption) {
  661. case PARAMS:
  662. lstrcpy(lpPEnha->params, rgszOption[1]);
  663. break;
  664. case CONVMEM:
  665. while ((rgszVal = RgszFromSzListValue(rgszOption[1])) == (RGSZ)NULL) {
  666. if (!FHandleOOM(hwndFrame)) {
  667. EvalAssert(FFreeRgsz(rgszOption));
  668. EvalAssert(FFreeRgsz(rgszEnhOptions));
  669. return (fFalse);
  670. }
  671. }
  672. if (rgszVal[0] == NULL || rgszVal[1] == NULL) {
  673. EvalAssert(FFreeRgsz(rgszVal));
  674. break;
  675. }
  676. if (!lstrcmp(rgszVal[0], "-1")) {
  677. lpPEnha->minmem = 0xFFFF;
  678. }
  679. else {
  680. lpPEnha->minmem = (WORD)atoi(rgszVal[0]);
  681. }
  682. if (!lstrcmp(rgszVal[1], "-1")) {
  683. lpPEnha->maxmem = 0xFFFF;
  684. }
  685. else {
  686. lpPEnha->maxmem = (WORD)atoi(rgszVal[1]);
  687. }
  688. EvalAssert(FFreeRgsz(rgszVal));
  689. break;
  690. case DISPLAY_USAGE:
  691. if (!lstrcmpi(rgszOption[1], FULL_SCREEN)) {
  692. lpPEnha->PfW386Flags |= fFullScrn;
  693. }
  694. else if (!lstrcmpi(rgszOption[1], WINDOWED_OPT)) {
  695. lpPEnha->PfW386Flags &= ~fFullScrn;
  696. }
  697. break;
  698. case EXEC_FLAGS:
  699. /* Reset bits that this case addresses. */
  700. lpPEnha->PfW386Flags &= ~(fBackground | fExclusive);
  701. while ((rgszVal = RgszFromSzListValue(rgszOption[1])) == (RGSZ)NULL) {
  702. if (!FHandleOOM(hwndFrame)) {
  703. EvalAssert(FFreeRgsz(rgszOption));
  704. EvalAssert(FFreeRgsz(rgszEnhOptions));
  705. return (fFalse);
  706. }
  707. }
  708. i = 0;
  709. while ((szVal = rgszVal[i++]) != (SZ)NULL) {
  710. if (!lstrcmpi(szVal, BACKGROUND)) {
  711. lpPEnha->PfW386Flags |= fBackground;
  712. }
  713. else if (!lstrcmpi(szVal, EXCLUSIVE)) {
  714. lpPEnha->PfW386Flags |= fExclusive;
  715. }
  716. }
  717. EvalAssert(FFreeRgsz(rgszVal));
  718. break;
  719. case MULTASK_OPT:
  720. while ((rgszVal = RgszFromSzListValue(rgszOption[1])) == (RGSZ)NULL) {
  721. if (!FHandleOOM(hwndFrame)) {
  722. EvalAssert(FFreeRgsz(rgszOption));
  723. EvalAssert(FFreeRgsz(rgszEnhOptions));
  724. return(fFalse);
  725. }
  726. }
  727. if (rgszVal[0] == NULL || rgszVal[1] == NULL) {
  728. EvalAssert(FFreeRgsz(rgszVal));
  729. break;
  730. }
  731. lpPEnha->PfBPriority = (WORD)atoi(rgszVal[0]);
  732. lpPEnha->PfFPriority = (WORD)atoi(rgszVal[1]);
  733. EvalAssert(FFreeRgsz(rgszVal));
  734. break;
  735. case EMSMEM:
  736. while ((rgszVal = RgszFromSzListValue(rgszOption[1])) == (RGSZ)NULL) {
  737. if (!FHandleOOM(hwndFrame)) {
  738. EvalAssert(FFreeRgsz(rgszOption));
  739. EvalAssert(FFreeRgsz(rgszEnhOptions));
  740. return(fFalse);
  741. }
  742. }
  743. if (rgszVal[0] == NULL || rgszVal[1] == NULL) {
  744. EvalAssert(FFreeRgsz(rgszVal));
  745. break;
  746. }
  747. lpPEnha->PfMinEMMK = (WORD)atoi(rgszVal[0]);
  748. if (!lstrcmp(rgszVal[1], "-1")) {
  749. lpPEnha->PfMaxEMMK = 0xFFFF;
  750. }
  751. else {
  752. lpPEnha->PfMaxEMMK = (WORD)atoi(rgszVal[1]);
  753. }
  754. EvalAssert(FFreeRgsz(rgszVal));
  755. break;
  756. case XMSMEM:
  757. while ((rgszVal = RgszFromSzListValue(rgszOption[1])) == (RGSZ)NULL) {
  758. if (!FHandleOOM(hwndFrame)) {
  759. EvalAssert(FFreeRgsz(rgszOption));
  760. EvalAssert(FFreeRgsz(rgszEnhOptions));
  761. return (fFalse);
  762. }
  763. }
  764. if (rgszVal[0] == NULL || rgszVal[1] == NULL) {
  765. EvalAssert(FFreeRgsz(rgszVal));
  766. break;
  767. }
  768. lpPEnha->PfMinXmsK = (WORD)atoi(rgszVal[0]);
  769. if (!lstrcmp(rgszVal[1], "-1")) {
  770. lpPEnha->PfMaxXmsK = 0xFFFF;
  771. }
  772. else {
  773. lpPEnha->PfMaxXmsK = (WORD)atoi(rgszVal[1]);
  774. }
  775. EvalAssert(FFreeRgsz(rgszVal));
  776. break;
  777. case PROC_MEM_FLAGS:
  778. /* Reset bits that this case addresses. */
  779. lpPEnha->PfW386Flags |= fNoHMA;
  780. lpPEnha->PfW386Flags &= ~(fPollingDetect | fEMSLocked |
  781. fXMSLocked | fVMLocked);
  782. while ((rgszVal = RgszFromSzListValue(rgszOption[1])) == (RGSZ)NULL) {
  783. if (!FHandleOOM(hwndFrame)) {
  784. EvalAssert(FFreeRgsz(rgszOption));
  785. EvalAssert(FFreeRgsz(rgszEnhOptions));
  786. return (fFalse);
  787. }
  788. }
  789. i = 0;
  790. while ((szVal = rgszVal[i++]) != (SZ)NULL) {
  791. if (!lstrcmpi(szVal, DETECT_IDLE_TIME)) {
  792. lpPEnha->PfW386Flags |= fPollingDetect;
  793. }
  794. else if (!lstrcmpi(szVal, EMS_LOCKED)) {
  795. lpPEnha->PfW386Flags |= fEMSLocked;
  796. }
  797. else if (!lstrcmpi(szVal, XMS_LOCKED)) {
  798. lpPEnha->PfW386Flags |= fXMSLocked;
  799. }
  800. else if (!lstrcmpi(szVal, USE_HIMEM_AREA)) {
  801. lpPEnha->PfW386Flags &= ~fNoHMA;
  802. }
  803. else if (!lstrcmpi(szVal, LOCK_APP_MEM)) {
  804. lpPEnha->PfW386Flags |= fVMLocked;
  805. }
  806. }
  807. EvalAssert(FFreeRgsz(rgszVal));
  808. break;
  809. case DISP_OPT_VIDEO:
  810. if (!lstrcmpi(rgszOption[1], TEXT_OPT)) {
  811. lpPEnha->PfW386Flags2 |= fVidTextMd;
  812. lpPEnha->PfW386Flags2 &= ~(fVidLowRsGrfxMd | fVidHghRsGrfxMd);
  813. }
  814. else if (!lstrcmpi(rgszOption[1], LO_RES_GRAPH)) {
  815. lpPEnha->PfW386Flags2 |= fVidLowRsGrfxMd;
  816. lpPEnha->PfW386Flags2 &= ~(fVidTextMd | fVidHghRsGrfxMd);
  817. }
  818. else if (!lstrcmpi(rgszOption[1], HI_RES_GRAPH)) {
  819. lpPEnha->PfW386Flags2 |= fVidHghRsGrfxMd;
  820. lpPEnha->PfW386Flags2 &= ~(fVidLowRsGrfxMd | fVidTextMd);
  821. }
  822. break;
  823. case DISP_OPT_PORTS:
  824. /* Reset bits that this case addresses. */
  825. lpPEnha->PfW386Flags2 |= fVidNoTrpTxt | fVidNoTrpLRGrfx |
  826. fVidNoTrpHRGrfx;
  827. while ((rgszVal = RgszFromSzListValue(rgszOption[1])) == (RGSZ)NULL) {
  828. if (!FHandleOOM(hwndFrame)) {
  829. EvalAssert(FFreeRgsz(rgszOption));
  830. EvalAssert(FFreeRgsz(rgszEnhOptions));
  831. return(fFalse);
  832. }
  833. }
  834. i = 0;
  835. while ((szVal = rgszVal[i++]) != (SZ)NULL) {
  836. if (!lstrcmpi(szVal, TEXT_OPT)) {
  837. lpPEnha->PfW386Flags2 &= ~fVidNoTrpTxt;
  838. }
  839. else if (!lstrcmpi(szVal, LO_RES_GRAPH)) {
  840. lpPEnha->PfW386Flags2 &= ~fVidNoTrpLRGrfx;
  841. }
  842. else if (!lstrcmpi(szVal, HI_RES_GRAPH)) {
  843. lpPEnha->PfW386Flags2 &= ~fVidNoTrpHRGrfx;
  844. }
  845. }
  846. EvalAssert(FFreeRgsz(rgszVal));
  847. break;
  848. case DISP_OPT_FLAGS:
  849. /* Reset bits that this case addresses. */
  850. lpPEnha->PfW386Flags2 &= ~(fVidTxtEmulate | fVidRetainAllo);
  851. while ((rgszVal = RgszFromSzListValue(rgszOption[1])) == (RGSZ)NULL) {
  852. if (!FHandleOOM(hwndFrame)) {
  853. EvalAssert(FFreeRgsz(rgszOption));
  854. EvalAssert(FFreeRgsz(rgszEnhOptions));
  855. return(fFalse);
  856. }
  857. }
  858. i = 0;
  859. while ((szVal = rgszVal[i++]) != (SZ)NULL) {
  860. if (!lstrcmpi(szVal, EMULATE_TEXT_MODE)) {
  861. lpPEnha->PfW386Flags2 |= fVidTxtEmulate;
  862. }
  863. else if (!lstrcmpi(szVal, RETAIN_VIDEO_MEM)) {
  864. lpPEnha->PfW386Flags2 |= fVidRetainAllo;
  865. }
  866. }
  867. EvalAssert(FFreeRgsz(rgszVal));
  868. break;
  869. case OTHER_OPTIONS:
  870. /* Reset bits that this case addresses. */
  871. lpPEnha->PfW386Flags &= ~(fINT16Paste | fEnableClose |
  872. fALTTABdis | fALTESCdis |
  873. fCTRLESCdis | fPRTSCdis |
  874. fALTPRTSCdis | fALTSPACEdis |
  875. fALTENTERdis);
  876. while ((rgszVal = RgszFromSzListValue(rgszOption[1])) == (RGSZ)NULL) {
  877. if (!FHandleOOM(hwndFrame)) {
  878. EvalAssert(FFreeRgsz(rgszOption));
  879. EvalAssert(FFreeRgsz(rgszEnhOptions));
  880. return (fFalse);
  881. }
  882. }
  883. i = 0;
  884. while ((szVal = rgszVal[i++]) != (SZ)NULL) {
  885. if (!lstrcmpi(szVal, ALLOW_FAST_PASTE))
  886. lpPEnha->PfW386Flags |= fINT16Paste;
  887. else if (!lstrcmpi(szVal, ALLOW_CLOSE_ACTIVE))
  888. lpPEnha->PfW386Flags |= fEnableClose;
  889. else if (!lstrcmpi(szVal, ALT_TAB))
  890. lpPEnha->PfW386Flags |= fALTTABdis;
  891. else if (!lstrcmpi(szVal, ALT_ESC))
  892. lpPEnha->PfW386Flags |= fALTESCdis;
  893. else if (!lstrcmpi(szVal, CTRL_ESC))
  894. lpPEnha->PfW386Flags |= fCTRLESCdis;
  895. else if (!lstrcmpi(szVal, PRSCRN))
  896. lpPEnha->PfW386Flags |= fPRTSCdis;
  897. else if (!lstrcmpi(szVal, ALT_PRSCRN))
  898. lpPEnha->PfW386Flags |= fALTPRTSCdis;
  899. else if (!lstrcmpi(szVal, ALT_SPACE))
  900. lpPEnha->PfW386Flags |= fALTSPACEdis;
  901. else if (!lstrcmpi(szVal, ALT_ENTER))
  902. lpPEnha->PfW386Flags |= fALTENTERdis;
  903. }
  904. EvalAssert(FFreeRgsz(rgszVal));
  905. break;
  906. default:
  907. break;
  908. }
  909. EvalAssert(FFreeRgsz(rgszOption));
  910. }
  911. EvalAssert(FFreeRgsz(rgszEnhOptions));
  912. if (bNoTrpHRGrfx) {
  913. lpPEnha->PfW386Flags2 |= fVidNoTrpHRGrfx;
  914. }
  915. return (fTrue);
  916. }
  917. /***************************************************************************
  918. GetExtOption
  919. ------------
  920. DESCRIPTION:
  921. This procedure will return an ID which defines the string switch
  922. from the APPS.INF line which was passed in.
  923. HISTORY:
  924. Modified by: Date: Comment:
  925. PAK 11/2/90 Created
  926. ***************************************************************************/
  927. INT
  928. GetExtOption(
  929. LPSTR lpsz
  930. )
  931. {
  932. if (!lstrcmpi(lpsz, "params")) {
  933. return PARAMS;
  934. }
  935. else if (!lstrcmpi(lpsz, "minconvmem")) {
  936. return MINCONVMEM;
  937. }
  938. else if (!lstrcmpi(lpsz, "videomode")) {
  939. return VIDEOMODE;
  940. }
  941. else if (!lstrcmpi(lpsz, "xmsmem")) {
  942. return XMSMEM;
  943. }
  944. else if (!lstrcmpi(lpsz, "checkboxes")) {
  945. return CHECKBOXES;
  946. }
  947. else if (!lstrcmpi(lpsz, "emsmem")) {
  948. return EMSMEM;
  949. }
  950. else if (!lstrcmpi(lpsz, "convmem")) {
  951. return CONVMEM;
  952. }
  953. else if (!lstrcmpi(lpsz, "dispusage")) {
  954. return DISPLAY_USAGE;
  955. }
  956. else if (!lstrcmpi(lpsz, "execflags")) {
  957. return EXEC_FLAGS;
  958. }
  959. else if (!lstrcmpi(lpsz, "multaskopt")) {
  960. return MULTASK_OPT;
  961. }
  962. else if (!lstrcmpi(lpsz, "procmemflags")) {
  963. return PROC_MEM_FLAGS;
  964. }
  965. else if (!lstrcmpi(lpsz, "dispoptvideo")) {
  966. return DISP_OPT_VIDEO;
  967. }
  968. else if (!lstrcmpi(lpsz, "dispoptports")) {
  969. return DISP_OPT_PORTS;
  970. }
  971. else if (!lstrcmpi(lpsz, "dispflags")) {
  972. return DISP_OPT_FLAGS;
  973. }
  974. else if (!lstrcmpi(lpsz, "otheroptions")) {
  975. return OTHER_OPTIONS;
  976. }
  977. else {
  978. return UNKNOWN_OPTION;
  979. }
  980. }
  981. /***************************************************************************
  982. FInitializePIFStructs
  983. --------------------
  984. DESCRIPTION:
  985. This procedure will allocate and initialize all PIF structures required
  986. to set up DOS applications.
  987. HISTORY:
  988. Modified by: Date: Comment:
  989. PAK 8/18/91 Created
  990. SUNILP 2/04/92 Modified to fit into Win32 GUI Setup
  991. ***************************************************************************/
  992. BOOL
  993. FInitializePIFStructs(
  994. BOOL bIsEnhanced,
  995. SZ szDfltStdOpt,
  996. SZ szDfltEnhOpt
  997. )
  998. {
  999. HDC hdc;
  1000. BOOL bStatus;
  1001. /* Initialize for enhanced/standard mode pifs */
  1002. bIs386 = bIsEnhanced;
  1003. /* Allcate a BIG block to contain all necessary PIF structures. This
  1004. block will be freed during ExitProcessing
  1005. */
  1006. cbAllPIF = bIs386 ? sizeof(PIF386Combined) : sizeof(PIF286Combined);
  1007. while ((lpAllPIF = SAlloc(cbAllPIF)) == NULL) {
  1008. if (!FHandleOOM(hwndFrame)) {
  1009. DestroyWindow(GetParent(hwndFrame));
  1010. return(fFalse);
  1011. }
  1012. }
  1013. memset( lpAllPIF, 0, cbAllPIF );
  1014. if (bIs386) {
  1015. lpDfltPIF = &(((LPPIF386Combined)lpAllPIF)->DfltPIF );
  1016. lpDfltStd = &(((LPPIF386Combined)lpAllPIF)->DfltStd );
  1017. lpDfltEnha = &(((LPPIF386Combined)lpAllPIF)->DfltEnha );
  1018. lpCurrPIF = &(((LPPIF386Combined)lpAllPIF)->CurrPIF );
  1019. lpStdExtHdr = &(((LPPIF386Combined)lpAllPIF)->StdExtHdr );
  1020. lpCurrStd = &(((LPPIF386Combined)lpAllPIF)->CurrStd );
  1021. lpEnhaExtHdr = &(((LPPIF386Combined)lpAllPIF)->EnhaExtHdr);
  1022. lpCurrEnha = &(((LPPIF386Combined)lpAllPIF)->CurrEnha );
  1023. }
  1024. else {
  1025. lpDfltPIF = &(((LPPIF286Combined)lpAllPIF)->DfltPIF );
  1026. lpDfltStd = &(((LPPIF286Combined)lpAllPIF)->DfltStd );
  1027. lpCurrPIF = &(((LPPIF286Combined)lpAllPIF)->CurrPIF );
  1028. lpStdExtHdr = &(((LPPIF286Combined)lpAllPIF)->StdExtHdr );
  1029. lpCurrStd = &(((LPPIF286Combined)lpAllPIF)->CurrStd );
  1030. }
  1031. /* Intialize PIF structure headers, these will be used by all created
  1032. PIFs. */
  1033. lstrcpy(lpDfltPIF->stdpifext.extsig, STDHDRSIG);
  1034. lpDfltPIF->stdpifext.extfileoffset = 0;
  1035. lpDfltPIF->stdpifext.extsizebytes = sizeof(PACKED_PIFNEWSTRUCT) -
  1036. sizeof(PIFEXTHEADER);
  1037. lpDfltPIF->stdpifext.extnxthdrfloff = sizeof(PACKED_PIFNEWSTRUCT);
  1038. lstrcpy(lpStdExtHdr->extsig, W286HDRSIG30);
  1039. lpStdExtHdr->extfileoffset = sizeof(PACKED_PIFNEWSTRUCT) + sizeof(PIFEXTHEADER);
  1040. lpStdExtHdr->extsizebytes = sizeof(PIF286EXT30);
  1041. if (!bIs386) {
  1042. lpStdExtHdr->extnxthdrfloff = LASTHEADERPTR;
  1043. }
  1044. else {
  1045. lpStdExtHdr->extnxthdrfloff = sizeof(PACKED_PIFNEWSTRUCT) +
  1046. sizeof(PIFEXTHEADER) +
  1047. sizeof(PIF286EXT30);
  1048. lpEnhaExtHdr->extfileoffset = sizeof(PACKED_PIFNEWSTRUCT) +
  1049. sizeof(PIFEXTHEADER) +
  1050. sizeof(PIF286EXT30) +
  1051. sizeof(PIFEXTHEADER);
  1052. lstrcpy(lpEnhaExtHdr->extsig, W386HDRSIG);
  1053. lpEnhaExtHdr->extsizebytes = sizeof(PIF386EXT);
  1054. lpEnhaExtHdr->extnxthdrfloff = LASTHEADERPTR;
  1055. }
  1056. /* Initialize values that will never change and are probably obsolete.
  1057. These values cannot be changed by the PIF editor, but probably have
  1058. some historical significance. */
  1059. lpDfltPIF->maxmem = 640;
  1060. lpDfltPIF->screen = 0x7f;
  1061. lpDfltPIF->cPages = 1;
  1062. lpDfltPIF->highVector = 0xff;
  1063. lpDfltPIF->rows = 25;
  1064. lpDfltPIF->cols = 80;
  1065. /* Set default standard and enhanced mode PIF settings from the
  1066. appropriate default sections contained in APPS.INF. */
  1067. bStatus = FProcessStdModeInfo(szDfltStdOpt, lpDfltPIF, lpDfltStd);
  1068. if (!bStatus) {
  1069. return (fFalse);
  1070. }
  1071. if (bIs386) {
  1072. bStatus = FProcessEnhaModeInfo(szDfltEnhOpt, lpDfltEnha);
  1073. if (!bStatus) {
  1074. return (fFalse);
  1075. }
  1076. }
  1077. /* Special case hack for VGA & 8514:
  1078. - Always disable hires graphics trapping
  1079. This is code from 3.0. This code means that if APPS.INF contains an
  1080. entry that enables Hires graphics trapping, this portion of code
  1081. will set a flag that will cause it to be disabled if a VGA or 8514
  1082. are present.
  1083. */
  1084. hdc = GetDC(NULL);
  1085. if ( GetDeviceCaps(hdc,VERTRES) == 350 ) {
  1086. bNoTrpHRGrfx = fFalse;
  1087. }
  1088. ReleaseDC(NULL,hdc);
  1089. return (fTrue);
  1090. }
  1091. /***************************************************************************
  1092. FreePIFstructs
  1093. --------------
  1094. DESCRIPTION:
  1095. This procedure will allocate and initialize all PIF structures required
  1096. to set up DOS applications.
  1097. HISTORY:
  1098. Modified by: Date: Comment:
  1099. PAK 8/18/91 Created
  1100. SUNILP 2/04/92 Modified to fit into Win32 GUI Setup
  1101. ***************************************************************************/
  1102. VOID
  1103. FreePIFStructs(
  1104. VOID
  1105. )
  1106. {
  1107. if (lpAllPIF) {
  1108. SFree(lpAllPIF);
  1109. //
  1110. // Reset all the pointers to this global memory to NULL
  1111. //
  1112. cbAllPIF = 0;
  1113. lpAllPIF = NULL;
  1114. lpDfltPIF = NULL;
  1115. lpCurrPIF = NULL;
  1116. lpStdExtHdr = NULL;
  1117. lpDfltStd = NULL;
  1118. lpCurrStd = NULL;
  1119. lpEnhaExtHdr = NULL;
  1120. lpDfltEnha = NULL;
  1121. lpCurrEnha = NULL;
  1122. }
  1123. return;
  1124. }
  1125. /***************************************************************************
  1126. ExtractStrFromPIF
  1127. -----------------
  1128. DESCRIPTION:
  1129. This procedure will remove trailing spaces from a descritpion string.
  1130. It is needed because PIFs created with the PIF editor have their
  1131. description string padded with spaces (' ').
  1132. HISTORY:
  1133. Modified by: Date: Comment:
  1134. PAK 8/6/91 Created
  1135. SUNILP 2/4/92 Modified to remove DBCS.
  1136. ***************************************************************************/
  1137. VOID
  1138. ExtractStrFromPIF(
  1139. LPSTR lpsz,
  1140. int n
  1141. )
  1142. {
  1143. int i = 0;
  1144. int iSpace = 0;
  1145. BOOL bSpaceFound = fFalse;
  1146. while ((i < n) && (lpsz[i] != '\0')) {
  1147. if (lpsz[i] == ' ') {
  1148. if (!bSpaceFound) {
  1149. bSpaceFound = fTrue;
  1150. iSpace = i;
  1151. }
  1152. }
  1153. else {
  1154. bSpaceFound = fFalse;
  1155. }
  1156. i++;
  1157. }
  1158. if (bSpaceFound) {
  1159. lpsz[iSpace] = '\0';
  1160. }
  1161. else {
  1162. lpsz[i] = '\0';
  1163. }
  1164. return;
  1165. }
  1166. /***************************************************************************
  1167. FInstallDOSPifs
  1168. ---------------
  1169. This is the main install routine which handles dos app installation.
  1170. The routine:
  1171. 1. Initialises PIF Structs with the defaults given
  1172. 2. Processes a DOS App list trying to create PIF For the app and adding
  1173. an item to the progman group for the app.
  1174. 3. Creating some base pifs. (NOT IMPLEMENTED)
  1175. 4. Cleaning up after everything is done.
  1176. ENTRY:
  1177. 1. szAppList: This is a list of all the app entries to be set up.
  1178. 2. szWinMode: ENHANCED | STANDARD
  1179. 3. szDefltStdValues: The defaults for standard mode options
  1180. 4. szDefltEnhValues: The defaults for enhanced mode options
  1181. 5. szPifDir: The directory for creating PIFs (e.g. d:\nt\)
  1182. 6. szGroup: The progman group which is to receive all the
  1183. DOS App items.
  1184. EXIT: BOOL: fTrue if successful
  1185. HISTORY:
  1186. Modified by: Date: Comment:
  1187. SUNILP 2/5/92 Created.
  1188. ***************************************************************************/
  1189. BOOL APIENTRY
  1190. FInstallDOSPifs(
  1191. SZ szAppList,
  1192. SZ szWinMode,
  1193. SZ szDefltStdValues,
  1194. SZ szDefltEnhValues,
  1195. SZ szPifDir,
  1196. SZ szGroup
  1197. )
  1198. {
  1199. ADDAPP_STATUS rc;
  1200. BOOL bIsEnhanced, bStatus;
  1201. RGSZ rgszGroupList, rgszAppList, rgszApp;
  1202. PSZ pszAppList;
  1203. SZ szApp;
  1204. INT nGroupFromList = 0;
  1205. //
  1206. // Since the "Applications" group may be full the szGroup is actually
  1207. // a list of possible group names including "Applications". We should
  1208. // try alternate group names in case the current one fails.
  1209. //
  1210. while ((rgszGroupList = RgszFromSzListValue(szGroup)) == (RGSZ)NULL) {
  1211. if (!FHandleOOM(hwndFrame)) {
  1212. return(fFalse);
  1213. }
  1214. }
  1215. Assert (rgszGroupList[nGroupFromList] != NULL);
  1216. // See Windows Mode we are operating in
  1217. //
  1218. bIsEnhanced = !lstrcmpi((LPSTR)szWinMode, (LPSTR)MODE_ENHANCED);
  1219. bStatus = FInitializePIFStructs(
  1220. bIsEnhanced,
  1221. szDefltStdValues,
  1222. szDefltEnhValues
  1223. );
  1224. if (!bStatus) {
  1225. EvalAssert(FFreeRgsz(rgszGroupList));
  1226. FreePIFStructs();
  1227. return fFalse;
  1228. }
  1229. //
  1230. // Process App List.
  1231. //
  1232. while ((pszAppList = rgszAppList = RgszFromSzListValue(szAppList)) == (RGSZ)NULL) {
  1233. if (!FHandleOOM(hwndFrame)) {
  1234. EvalAssert(FFreeRgsz(rgszGroupList));
  1235. FreePIFStructs();
  1236. return(fFalse);
  1237. }
  1238. }
  1239. while ((szApp = *pszAppList++) != (SZ)NULL) {
  1240. while ((rgszApp = RgszFromSzListValue(szApp)) == (RGSZ)NULL) {
  1241. if (!FHandleOOM(hwndFrame)) {
  1242. EvalAssert(FFreeRgsz(rgszGroupList));
  1243. EvalAssert(FFreeRgsz(rgszAppList));
  1244. FreePIFStructs();
  1245. return(fFalse);
  1246. }
  1247. }
  1248. //
  1249. // Check the app type, whether it is a win16/win32 or dos app
  1250. //
  1251. if ( (CrcStringCompareI(rgszApp[nEXETYPE], EXE_WIN16_SZ) == crcEqual) ||
  1252. (CrcStringCompareI(rgszApp[nEXETYPE], EXE_WIN32_SZ) == crcEqual)
  1253. ) {
  1254. while ((rc = AddWinItem(
  1255. rgszApp,
  1256. rgszGroupList[nGroupFromList]
  1257. )) != ADDAPP_SUCCESS) {
  1258. if ( rc == ADDAPP_GRPFAIL &&
  1259. rgszGroupList[++nGroupFromList] != NULL
  1260. ) {
  1261. }
  1262. else {
  1263. bStatus = fFalse;
  1264. break;
  1265. }
  1266. }
  1267. }
  1268. else if (CrcStringCompareI(rgszApp[nEXETYPE], EXE_DOS_SZ) == crcEqual) {
  1269. while ((rc = AddDosAppItem(
  1270. rgszApp,
  1271. szPifDir,
  1272. rgszGroupList[nGroupFromList]
  1273. )) != ADDAPP_SUCCESS) {
  1274. if ( rc == ADDAPP_GRPFAIL &&
  1275. rgszGroupList[++nGroupFromList] != NULL
  1276. ) {
  1277. }
  1278. else {
  1279. bStatus = fFalse;
  1280. break;
  1281. }
  1282. }
  1283. }
  1284. EvalAssert(FFreeRgsz(rgszApp));
  1285. if (!bStatus) {
  1286. break;
  1287. }
  1288. }
  1289. //
  1290. // Minimize application groups, just in case one of them
  1291. // has overlaid a main group.
  1292. //
  1293. if(bStatus) {
  1294. INT i;
  1295. CHAR min[10];
  1296. wsprintf(min,"%u",SW_MINIMIZE);
  1297. for(i=0; i<=nGroupFromList; i++) {
  1298. FShowProgManGroup(
  1299. rgszGroupList[i],
  1300. min,
  1301. cmoNone,
  1302. TRUE
  1303. );
  1304. }
  1305. }
  1306. //
  1307. // Clean Up
  1308. //
  1309. EvalAssert(FFreeRgsz(rgszGroupList));
  1310. EvalAssert(FFreeRgsz(rgszAppList));
  1311. FreePIFStructs();
  1312. return(bStatus);
  1313. }