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.

1369 lines
42 KiB

  1. #include "shellprv.h"
  2. #pragma hdrstop
  3. extern PROPTSK tskDefault;
  4. extern PROPVID vidDefault;
  5. extern PROPMEM memDefault;
  6. extern PROPKBD kbdDefault;
  7. extern WORD flWinDefault;
  8. #define _LP386_ ((LPW386PIF30)aDataPtrs[LP386_INDEX])
  9. #define _LPENH_ ((LPWENHPIF40)aDataPtrs[LPENH_INDEX])
  10. #define _LPWNT40_ ((LPWNTPIF40)aDataPtrs[LPNT40_INDEX])
  11. #define _LPWNT31_ ((LPWNTPIF31)aDataPtrs[LPNT31_INDEX])
  12. extern const TCHAR szDefIconFile[];
  13. /*
  14. * INPUT
  15. * ppl -> property (assumes it is LOCKED)
  16. * lp386 -> 386 PIF data (may be NULL)
  17. * lpenh -> enhanced PIF data (may be NULL)
  18. * lpPrg -> where to store program property data
  19. * cb = sizeof property data
  20. *
  21. * OUTPUT
  22. * # of bytes returned
  23. */
  24. int GetPrgData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPPRG lpPrg, int cb, UINT flOpt)
  25. {
  26. LPSTR lpsz;
  27. LPPIFDATA lppd;
  28. FunctionName(GetPrgData);
  29. if (!(NULL != (lppd = ppl->lpPIFData)) || cb < sizeof(PROPPRG))
  30. return 0;
  31. lpPrg->flPrg = PRG_DEFAULT;
  32. lpPrg->flPrgInit = PRGINIT_DEFAULT;
  33. lpPrg->dwRealModeFlags = 0;
  34. lpPrg->flPrgInit |= ppl->flProp & (PROP_NOPIF | PROP_DEFAULTPIF | PROP_INFSETTINGS);
  35. PifMgr_WCtoMBPath( (LPWSTR)szDefIconFile, lpPrg->achIconFile, ARRAYSIZE(lpPrg->achIconFile) );
  36. PifMgr_WCtoMBPath( ppl->ofPIF.szPathName, lpPrg->achPIFFile, ARRAYSIZE(lpPrg->achPIFFile) );
  37. lpPrg->wIconIndex = ICONINDEX_DEFAULT;
  38. if (lppd->stdpifdata.MSflags & EXITMASK)
  39. lpPrg->flPrg |= PRG_CLOSEONEXIT;
  40. lstrcpytrimA(lpPrg->achTitle, lppd->stdpifdata.appname, ARRAYSIZE(lppd->stdpifdata.appname));
  41. cb = lstrcpyfnameA(lpPrg->achCmdLine, lppd->stdpifdata.startfile, ARRAYSIZE(lpPrg->achCmdLine));
  42. lpsz = lppd->stdpifdata.params;
  43. if (aDataPtrs[ LP386_INDEX ]) {
  44. lpsz = _LP386_->PfW386params;
  45. CTASSERTF(PRGINIT_MINIMIZED == (fMinimized >> fMinimizedBit));
  46. CTASSERTF(PRGINIT_MAXIMIZED == (fMaximized >> fMinimizedBit));
  47. CTASSERTF(PRGINIT_REALMODE == (fRealMode >> fMinimizedBit));
  48. CTASSERTF(PRGINIT_REALMODESILENT == (fRealModeSilent >> fMinimizedBit));
  49. CTASSERTF(PRGINIT_QUICKSTART == (fQuickStart >> fMinimizedBit));
  50. CTASSERTF(PRGINIT_AMBIGUOUSPIF == (fAmbiguousPIF >> fMinimizedBit));
  51. if (_LP386_->PfW386Flags & fWinLie)
  52. lpPrg->flPrgInit |= PRGINIT_WINLIE;
  53. if (_LP386_->PfW386Flags & fNoSuggestMSDOS)
  54. lpPrg->flPrg |= PRG_NOSUGGESTMSDOS;
  55. lpPrg->flPrgInit |= (WORD)((_LP386_->PfW386Flags & (fMinimized | fMaximized | fRealMode | fRealModeSilent | fQuickStart | fAmbiguousPIF)) >> fMinimizedBit);
  56. if (_LP386_->PfW386Flags & fHasHotKey) {
  57. lpPrg->wHotKey = HotKeyWindowsFromOem((LPPIFKEY)&_LP386_->PfHotKeyScan);
  58. } else {
  59. lpPrg->wHotKey = 0;
  60. }
  61. }
  62. if (*lpsz && ((int)(lstrlenA(lpsz)) < (int)(ARRAYSIZE(lpPrg->achCmdLine)-cb-1))) {
  63. lstrcatA(lpPrg->achCmdLine, " ");
  64. lstrcatA(lpPrg->achCmdLine, lpsz);
  65. }
  66. lstrcpyfnameA(lpPrg->achWorkDir, lppd->stdpifdata.defpath, ARRAYSIZE(lpPrg->achWorkDir));
  67. if (_LPENH_) {
  68. if (_LPENH_->achIconFileProp[0]) {
  69. lstrcpyA(lpPrg->achIconFile, _LPENH_->achIconFileProp);
  70. lpPrg->wIconIndex = _LPENH_->wIconIndexProp;
  71. }
  72. lpPrg->dwEnhModeFlags = _LPENH_->dwEnhModeFlagsProp;
  73. lpPrg->dwRealModeFlags = _LPENH_->dwRealModeFlagsProp;
  74. lstrcpyA(lpPrg->achOtherFile, _LPENH_->achOtherFileProp);
  75. }
  76. if (!(flOpt & GETPROPS_OEM)) {
  77. /* Convert all strings from OEM character set to Ansi */
  78. OemToCharA(lpPrg->achTitle, lpPrg->achTitle);
  79. OemToCharA(lpPrg->achCmdLine, lpPrg->achCmdLine);
  80. OemToCharA(lpPrg->achWorkDir, lpPrg->achWorkDir);
  81. }
  82. return sizeof(PROPPRG);
  83. }
  84. /** SetPrgData - set program property data
  85. *
  86. * INPUT
  87. * ppl -> property (assumes it is LOCKED)
  88. * lp386 -> 386 PIF data (GUARANTEED!)
  89. * lpenh -> enhanced PIF data (GUARANTEED!)
  90. * lpPrg -> where to store program property data
  91. * cb = sizeof property data
  92. *
  93. * OUTPUT
  94. * # of bytes set
  95. */
  96. int SetPrgData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPPRG lpPrg, int cb, UINT flOpt)
  97. {
  98. int i;
  99. LPPIFDATA lppd;
  100. FunctionName(SetPrgData);
  101. if (!(NULL != (lppd = ppl->lpPIFData)) || cb < sizeof(PROPPRG))
  102. return 0;
  103. lppd->stdpifdata.MSflags &= ~EXITMASK;
  104. if (lpPrg->flPrg & PRG_CLOSEONEXIT)
  105. lppd->stdpifdata.MSflags |= EXITMASK;
  106. CTASSERTF(PRGINIT_MINIMIZED == (fMinimized >> fMinimizedBit));
  107. CTASSERTF(PRGINIT_MAXIMIZED == (fMaximized >> fMinimizedBit));
  108. CTASSERTF(PRGINIT_REALMODE == (fRealMode >> fMinimizedBit));
  109. CTASSERTF(PRGINIT_REALMODESILENT == (fRealModeSilent >> fMinimizedBit));
  110. CTASSERTF(PRGINIT_QUICKSTART == (fQuickStart >> fMinimizedBit));
  111. CTASSERTF(PRGINIT_AMBIGUOUSPIF == (fAmbiguousPIF >> fMinimizedBit));
  112. _LP386_->PfW386Flags &= ~(fHasHotKey | fWinLie | fMinimized | fMaximized | fRealMode | fRealModeSilent | fQuickStart | fAmbiguousPIF | fNoSuggestMSDOS);
  113. if (lpPrg->wHotKey)
  114. _LP386_->PfW386Flags |= fHasHotKey;
  115. if (!(lpPrg->flPrg & PRGINIT_WINLIE))
  116. _LP386_->PfW386Flags |= fWinLie;
  117. if (lpPrg->flPrg & PRG_NOSUGGESTMSDOS)
  118. _LP386_->PfW386Flags |= fNoSuggestMSDOS;
  119. _LP386_->PfW386Flags |= (DWORD)(lpPrg->flPrgInit & (PRGINIT_MINIMIZED | PRGINIT_MAXIMIZED | PRGINIT_REALMODE | PRGINIT_REALMODESILENT | PRGINIT_QUICKSTART | PRGINIT_AMBIGUOUSPIF)) << fMinimizedBit;
  120. lstrcpypadA(lppd->stdpifdata.appname, lpPrg->achTitle, ARRAYSIZE(lppd->stdpifdata.appname));
  121. lstrunquotefnameA(lppd->stdpifdata.startfile, lpPrg->achCmdLine, ARRAYSIZE(lppd->stdpifdata.startfile), FALSE);
  122. i = lstrskipfnameA(lpPrg->achCmdLine);
  123. i += lstrskipcharA(lpPrg->achCmdLine+i, ' ');
  124. lstrcpynA(lppd->stdpifdata.params, lpPrg->achCmdLine+i, ARRAYSIZE(lppd->stdpifdata.params));
  125. lstrcpynA(_LP386_->PfW386params, lpPrg->achCmdLine+i, ARRAYSIZE(_LP386_->PfW386params));
  126. if (lpPrg->achWorkDir[0] != '\"')
  127. lstrcpyA(lppd->stdpifdata.defpath, lpPrg->achWorkDir);
  128. else
  129. lstrunquotefnameA(lppd->stdpifdata.defpath, lpPrg->achWorkDir, ARRAYSIZE(lppd->stdpifdata.defpath), FALSE);
  130. HotKeyOemFromWindows((LPPIFKEY)&_LP386_->PfHotKeyScan, lpPrg->wHotKey);
  131. lstrcpynA(_LPENH_->achIconFileProp, lpPrg->achIconFile, ARRAYSIZE(_LPENH_->achIconFileProp));
  132. _LPENH_->wIconIndexProp = lpPrg->wIconIndex;
  133. _LPENH_->dwEnhModeFlagsProp = lpPrg->dwEnhModeFlags;
  134. _LPENH_->dwRealModeFlagsProp = lpPrg->dwRealModeFlags;
  135. lstrcpynA(_LPENH_->achOtherFileProp, lpPrg->achOtherFile, ARRAYSIZE(_LPENH_->achOtherFileProp));
  136. MultiByteToWideChar( CP_ACP, 0,
  137. lpPrg->achPIFFile, -1,
  138. ppl->ofPIF.szPathName,
  139. ARRAYSIZE(ppl->ofPIF.szPathName)
  140. );
  141. if (!(flOpt & SETPROPS_OEM)) {
  142. /* Convert all strings from Ansi character set to OEM */
  143. CharToOemBuffA(lppd->stdpifdata.appname, lppd->stdpifdata.appname, ARRAYSIZE(lppd->stdpifdata.appname));
  144. CharToOemA(lppd->stdpifdata.startfile, lppd->stdpifdata.startfile);
  145. CharToOemA(lppd->stdpifdata.defpath, lppd->stdpifdata.defpath);
  146. CharToOemA(lppd->stdpifdata.params, lppd->stdpifdata.params);
  147. }
  148. ppl->flProp |= PROP_DIRTY;
  149. return sizeof(PROPPRG);
  150. }
  151. /*
  152. * INPUT
  153. * ppl -> property (assumes it is LOCKED)
  154. * lp386 -> 386 PIF data (may be NULL)
  155. * lpenh -> enhanced PIF data (may be NULL)
  156. * lpTsk -> where to store tasking property data
  157. * cb = sizeof property data
  158. *
  159. * OUTPUT
  160. * # of bytes returned
  161. */
  162. int GetTskData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPTSK lpTsk, int cb, UINT flOpt)
  163. {
  164. // Set defaults in case no appropriate section exists
  165. *lpTsk = tskDefault;
  166. // If an enh section exists, get it
  167. if (_LPENH_)
  168. *lpTsk = _LPENH_->tskProp;
  169. // Get any data that must still be maintained in the old 386 section
  170. if (_LP386_) {
  171. lpTsk->flTsk &= ~(TSK_ALLOWCLOSE | TSK_BACKGROUND | TSK_EXCLUSIVE);
  172. lpTsk->flTsk |= _LP386_->PfW386Flags & (fEnableClose | fBackground);
  173. if (!(_LP386_->PfW386Flags & fPollingDetect))
  174. lpTsk->wIdleSensitivity = 0;
  175. }
  176. return sizeof(PROPTSK);
  177. }
  178. /** SetTskData - set tasking property data
  179. *
  180. * INPUT
  181. * ppl -> property (assumes it is LOCKED)
  182. * lp386 -> 386 PIF data (GUARANTEED!)
  183. * lpenh -> enhanced PIF data (GUARANTEED!)
  184. * lpTsk -> where to store tasking property data
  185. * cb = sizeof property data
  186. *
  187. * OUTPUT
  188. * # of bytes set
  189. */
  190. int SetTskData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPTSK lpTsk, int cb, UINT flOpt)
  191. {
  192. _LPENH_->tskProp = *lpTsk;
  193. _LP386_->PfW386Flags &= ~(fEnableClose | fBackground | fExclusive | fPollingDetect);
  194. _LP386_->PfW386Flags |= (lpTsk->flTsk & (TSK_ALLOWCLOSE | TSK_BACKGROUND));
  195. if (lpTsk->wIdleSensitivity)
  196. _LP386_->PfW386Flags |= fPollingDetect;
  197. ppl->flProp |= PROP_DIRTY;
  198. return sizeof(PROPTSK);
  199. }
  200. /** GetVidData - get video property data
  201. *
  202. * INPUT
  203. * ppl -> property (assumes it is LOCKED)
  204. * lp386 -> 386 PIF data (may be NULL)
  205. * lpenh -> enhanced PIF data (may be NULL)
  206. * lpVid -> where to store video property data
  207. * cb = sizeof property data
  208. *
  209. * OUTPUT
  210. * # of bytes returned
  211. */
  212. int GetVidData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPVID lpVid, int cb, UINT flOpt)
  213. {
  214. // Set defaults in case no appropriate section exists
  215. *lpVid = vidDefault;
  216. // If an enh section exists, get it
  217. if (_LPENH_)
  218. *lpVid = _LPENH_->vidProp;
  219. // Get any data that must still be maintained in the old 386 section
  220. if (_LP386_) {
  221. // Clear bits that already existed in the 386 section
  222. lpVid->flVid &= ~(VID_TEXTEMULATE | VID_RETAINMEMORY | VID_FULLSCREEN);
  223. lpVid->flVid |= _LP386_->PfW386Flags2 & (fVidTxtEmulate | fVidRetainAllo);
  224. if (_LP386_->PfW386Flags & fFullScreen)
  225. lpVid->flVid |= VID_FULLSCREEN;
  226. }
  227. return sizeof(PROPVID);
  228. }
  229. /** SetVidData - set video property data
  230. *
  231. * INPUT
  232. * ppl -> property (assumes it is LOCKED)
  233. * lp386 -> 386 PIF data (GUARANTEED!)
  234. * lpenh -> enhanced PIF data (GUARANTEED!)
  235. * lpVid -> where to store video property data
  236. * cb = sizeof property data
  237. *
  238. * OUTPUT
  239. * # of bytes set
  240. */
  241. int SetVidData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPVID lpVid, int cb, UINT flOpt)
  242. {
  243. _LPENH_->vidProp = *lpVid;
  244. _LP386_->PfW386Flags &= ~(fFullScreen);
  245. if (lpVid->flVid & VID_FULLSCREEN)
  246. _LP386_->PfW386Flags |= fFullScreen;
  247. _LP386_->PfW386Flags2 &= ~(fVidTxtEmulate | fVidRetainAllo);
  248. _LP386_->PfW386Flags2 |= lpVid->flVid & (fVidTxtEmulate | fVidRetainAllo);
  249. ppl->flProp |= PROP_DIRTY;
  250. return sizeof(PROPVID);
  251. }
  252. /** GetMemData - get memory property data
  253. *
  254. * INPUT
  255. * ppl -> property (assumes it is LOCKED)
  256. * lp386 -> 386 PIF data (may be NULL)
  257. * lpenh -> enhanced PIF data (NOT USED)
  258. * lpMem -> where to store memory property data
  259. * cb = sizeof property data
  260. *
  261. * OUTPUT
  262. * # of bytes returned
  263. */
  264. int GetMemData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPMEM lpMem, int cb, UINT flOpt)
  265. {
  266. // Set defaults in case no appropriate section exists
  267. *lpMem = memDefault;
  268. // Get any data that must still be maintained in the old 386 section
  269. if (_LP386_) {
  270. // Clear bits that already exist in the 386 section
  271. lpMem->flMemInit &= ~(MEMINIT_NOHMA |
  272. MEMINIT_LOWLOCKED |
  273. MEMINIT_EMSLOCKED |
  274. MEMINIT_XMSLOCKED |
  275. MEMINIT_GLOBALPROTECT |
  276. MEMINIT_LOCALUMBS |
  277. MEMINIT_STRAYPTRDETECT);
  278. if (_LP386_->PfW386Flags & fNoHMA)
  279. lpMem->flMemInit |= MEMINIT_NOHMA;
  280. if (_LP386_->PfW386Flags & fVMLocked)
  281. lpMem->flMemInit |= MEMINIT_LOWLOCKED;
  282. if (_LP386_->PfW386Flags & fEMSLocked)
  283. lpMem->flMemInit |= MEMINIT_EMSLOCKED;
  284. if (_LP386_->PfW386Flags & fXMSLocked)
  285. lpMem->flMemInit |= MEMINIT_XMSLOCKED;
  286. if (_LP386_->PfW386Flags & fGlobalProtect)
  287. lpMem->flMemInit |= MEMINIT_GLOBALPROTECT;
  288. if (_LP386_->PfW386Flags & fLocalUMBs)
  289. lpMem->flMemInit |= MEMINIT_LOCALUMBS;
  290. // NOTE: we don't provide a UI for this (debugging) feature, but all
  291. // the support is still in place.
  292. if (_LP386_->PfW386Flags & fStrayPtrDetect)
  293. lpMem->flMemInit |= MEMINIT_STRAYPTRDETECT;
  294. lpMem->wMinLow = _LP386_->PfW386minmem;
  295. lpMem->wMinEMS = _LP386_->PfMinEMMK;
  296. lpMem->wMinXMS = _LP386_->PfMinXmsK;
  297. lpMem->wMaxLow = _LP386_->PfW386maxmem;
  298. lpMem->wMaxEMS = _LP386_->PfMaxEMMK;
  299. lpMem->wMaxXMS = _LP386_->PfMaxXmsK;
  300. }
  301. return sizeof(PROPMEM);
  302. }
  303. /** SetMemData - set memory property data
  304. *
  305. * INPUT
  306. * ppl -> property (assumes it is LOCKED)
  307. * lp386 -> 386 PIF data (GUARANTEED!)
  308. * lpenh -> enhanced PIF data (NOT USED)
  309. * lpMem -> where to store memory property data
  310. * cb = sizeof property data
  311. *
  312. * OUTPUT
  313. * # of bytes set
  314. */
  315. int SetMemData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPMEM lpMem, int cb, UINT flOpt)
  316. {
  317. _LP386_->PfW386Flags &= ~(fNoHMA |
  318. fVMLocked |
  319. fEMSLocked |
  320. fXMSLocked |
  321. fGlobalProtect |
  322. fLocalUMBs |
  323. fStrayPtrDetect);
  324. if (lpMem->flMemInit & MEMINIT_NOHMA)
  325. _LP386_->PfW386Flags |= fNoHMA;
  326. // Note that we now only honor updating the locked memory bits
  327. // if the corresponding memory quantity has been set to a SPECIFIC
  328. // value. We want to avoid someone changing a memory setting to
  329. // "Automatic" and having an indeterminate amount of memory inadvertently
  330. // locked. -JTP
  331. if ((lpMem->flMemInit & MEMINIT_LOWLOCKED) && (lpMem->wMinLow == lpMem->wMaxLow))
  332. _LP386_->PfW386Flags |= fVMLocked;
  333. if ((lpMem->flMemInit & MEMINIT_EMSLOCKED) && (lpMem->wMinEMS == lpMem->wMaxEMS))
  334. _LP386_->PfW386Flags |= fEMSLocked;
  335. if ((lpMem->flMemInit & MEMINIT_XMSLOCKED) && (lpMem->wMinXMS == lpMem->wMaxXMS))
  336. _LP386_->PfW386Flags |= fXMSLocked;
  337. if (lpMem->flMemInit & MEMINIT_GLOBALPROTECT)
  338. _LP386_->PfW386Flags |= fGlobalProtect;
  339. if (lpMem->flMemInit & MEMINIT_LOCALUMBS)
  340. _LP386_->PfW386Flags |= fLocalUMBs;
  341. if (lpMem->flMemInit & MEMINIT_STRAYPTRDETECT)
  342. _LP386_->PfW386Flags |= fStrayPtrDetect;
  343. _LP386_->PfW386minmem = lpMem->wMinLow;
  344. _LP386_->PfMinEMMK = lpMem->wMinEMS;
  345. _LP386_->PfMinXmsK = lpMem->wMinXMS;
  346. _LP386_->PfW386maxmem = lpMem->wMaxLow;
  347. _LP386_->PfMaxEMMK = lpMem->wMaxEMS;
  348. _LP386_->PfMaxXmsK = lpMem->wMaxXMS;
  349. ppl->flProp |= PROP_DIRTY;
  350. return sizeof(PROPMEM);
  351. }
  352. /*
  353. * INPUT
  354. * ppl -> property (assumes it is LOCKED)
  355. * lp386 -> 386 PIF data (may be NULL)
  356. * lpenh -> enhanced PIF data (may be NULL)
  357. * lpKbd -> where to store keyboard property data
  358. * cb = sizeof property data
  359. *
  360. * OUTPUT
  361. * # of bytes returned
  362. */
  363. int GetKbdData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPKBD lpKbd, int cb, UINT flOpt)
  364. {
  365. // Set defaults in case no appropriate section exists
  366. *lpKbd = kbdDefault;
  367. // If an enh section exists, get it
  368. if (_LPENH_)
  369. *lpKbd = _LPENH_->kbdProp;
  370. // Perform limited validation; there are a variety of places we can
  371. // do validation (at the time defaults are captured from SYSTEM.INI,
  372. // and whenever properties are saved), but minimum validation requires
  373. // we at least check the values we're returning to the outside world
  374. //
  375. // I would also say that as a general rule ring 0 code should never
  376. // trust data coming from ring 3 as fully validated. In addition, the
  377. // UI layer will want to do input validation to provide immediate feedback,
  378. // so validation in this layer seems pretty non-worthwhile.
  379. if (lpKbd->msAltDelay == 0) // we know this is bad at any rate
  380. lpKbd->msAltDelay = KBDALTDELAY_DEFAULT;
  381. // Get any data that must still be maintained in the old 386 section
  382. if (_LP386_) {
  383. // Clear bits that already exist in the 386 section
  384. lpKbd->flKbd &= ~(KBD_FASTPASTE |
  385. KBD_NOALTTAB |
  386. KBD_NOALTESC |
  387. KBD_NOALTSPACE |
  388. KBD_NOALTENTER |
  389. KBD_NOALTPRTSC |
  390. KBD_NOPRTSC |
  391. KBD_NOCTRLESC);
  392. lpKbd->flKbd |= _LP386_->PfW386Flags & (fALTTABdis | fALTESCdis | fALTSPACEdis | fALTENTERdis | fALTPRTSCdis | fPRTSCdis | fCTRLESCdis);
  393. if (_LP386_->PfW386Flags & fINT16Paste)
  394. lpKbd->flKbd |= KBD_FASTPASTE;
  395. }
  396. return sizeof(PROPKBD);
  397. }
  398. /** SetKbdData - set keyboard property data
  399. *
  400. * INPUT
  401. * ppl -> property (assumes it is LOCKED)
  402. * lp386 -> 386 PIF data (GUARANTEED!)
  403. * _LPENH_ -> enhanced PIF data (GUARANTEED!)
  404. * lpKbd -> where to store keyboard property data
  405. * cb = sizeof property data
  406. *
  407. * OUTPUT
  408. * # of bytes set
  409. */
  410. int SetKbdData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPKBD lpKbd, int cb, UINT flOpt)
  411. {
  412. _LPENH_->kbdProp = *lpKbd;
  413. _LP386_->PfW386Flags &= ~fINT16Paste;
  414. if (lpKbd->flKbd & KBD_FASTPASTE)
  415. _LP386_->PfW386Flags |= fINT16Paste;
  416. _LP386_->PfW386Flags &= ~(fALTTABdis | fALTESCdis | fALTSPACEdis | fALTENTERdis | fALTPRTSCdis | fPRTSCdis | fCTRLESCdis);
  417. _LP386_->PfW386Flags |= lpKbd->flKbd & (fALTTABdis | fALTESCdis | fALTSPACEdis | fALTENTERdis | fALTPRTSCdis | fPRTSCdis | fCTRLESCdis);
  418. ppl->flProp |= PROP_DIRTY;
  419. return sizeof(PROPKBD);
  420. }
  421. /*
  422. * INPUT
  423. * ppl -> property (assumes it is LOCKED)
  424. * ((LPW386PIF30)aDataPtrs[ LP386_INDEX ]) -> 386 PIF data (NOT USED)
  425. * lpenh -> enhanced PIF data (may be NULL)
  426. * lpMse -> where to store mouse property data
  427. * cb = sizeof property data
  428. *
  429. * OUTPUT
  430. * # of bytes returned
  431. */
  432. int GetMseData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPMSE lpMse, int cb, UINT flOpt)
  433. {
  434. lpMse->flMse = MSE_DEFAULT;
  435. lpMse->flMseInit = MSEINIT_DEFAULT;
  436. if (_LPENH_)
  437. *lpMse = _LPENH_->mseProp;
  438. return sizeof(PROPMSE);
  439. }
  440. /** SetMseData - set mouse property data
  441. *
  442. * INPUT
  443. * ppl -> property (assumes it is LOCKED)
  444. * lp386 -> 386 PIF data (NOT USED)
  445. * lpenh -> enhanced PIF data (GUARANTEED!)
  446. * lpMse -> where to store mouse property data
  447. * cb = sizeof property data
  448. *
  449. * OUTPUT
  450. * # of bytes set
  451. */
  452. int SetMseData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPMSE lpMse, int cb, UINT flOpt)
  453. {
  454. FunctionName(SetMseData);
  455. _LPENH_->mseProp = *lpMse;
  456. ppl->flProp |= PROP_DIRTY;
  457. return sizeof(PROPMSE);
  458. }
  459. /** GetSndData - get sound property data
  460. *
  461. * INPUT
  462. * ppl -> property (assumes it is LOCKED)
  463. * lp386 -> 386 PIF data (NOT USED)
  464. * lpenh -> enhanced PIF data (may be NULL)
  465. * lpSnd -> where to store sound property data
  466. * cb = sizeof property data
  467. *
  468. * OUTPUT
  469. * # of bytes returned
  470. */
  471. int GetSndData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPSND lpSnd, int cb, UINT flOpt)
  472. {
  473. lpSnd->flSnd = SND_DEFAULT;
  474. lpSnd->flSndInit = SNDINIT_DEFAULT;
  475. if (_LPENH_)
  476. *lpSnd = _LPENH_->sndProp;
  477. return sizeof(PROPSND);
  478. }
  479. /** SetSndData - set sound property data
  480. *
  481. * INPUT
  482. * ppl -> property (assumes it is LOCKED)
  483. * lp386 -> 386 PIF data (NOT USED)
  484. * lpenh -> enhanced PIF data (GUARANTEED!)
  485. * lpSnd -> where to store sound property data
  486. * cb = sizeof property data
  487. *
  488. * OUTPUT
  489. * # of bytes set
  490. */
  491. int SetSndData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPSND lpSnd, int cb, UINT flOpt)
  492. {
  493. _LPENH_->sndProp = *lpSnd;
  494. ppl->flProp |= PROP_DIRTY;
  495. return sizeof(PROPSND);
  496. }
  497. /** GetFntData - get font property data
  498. *
  499. * INPUT
  500. * ppl -> property (assumes it is LOCKED)
  501. * lp386 -> 386 PIF data (NOT USED)
  502. * lpenh -> enhanced PIF data (may be NULL)
  503. * lpFnt -> where to store font property data
  504. * cb = sizeof property data
  505. *
  506. * OUTPUT
  507. * # of bytes returned
  508. */
  509. int GetFntData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPFNT lpFnt, int cb, UINT flOpt)
  510. {
  511. int iCount;
  512. BPFDI bpfdi;
  513. INIINFO iiTemp;
  514. lpFnt->flFnt = FNT_DEFAULT;
  515. lpFnt->wCurrentCP = (WORD) g_uCodePage;
  516. if (_LPENH_) {
  517. //
  518. // If we don't have any actual font data, see if we can compute some
  519. //
  520. if (!_LPENH_->fntProp.cxFontActual && _LPENH_->winProp.cxCells)
  521. _LPENH_->fntProp.cxFontActual = _LPENH_->winProp.cxClient / _LPENH_->winProp.cxCells;
  522. if (!_LPENH_->fntProp.cyFontActual && _LPENH_->winProp.cyCells)
  523. _LPENH_->fntProp.cyFontActual = _LPENH_->winProp.cyClient / _LPENH_->winProp.cyCells;
  524. *lpFnt = _LPENH_->fntProp;
  525. if (lpFnt->flFnt & FNT_AUTOSIZE) {
  526. bpfdi = ChooseBestFont(_LPENH_->winProp.cxCells,
  527. _LPENH_->winProp.cyCells,
  528. _LPENH_->winProp.cxClient,
  529. _LPENH_->winProp.cyClient,
  530. _LPENH_->fntProp.flFnt,
  531. _LPENH_->fntProp.wCurrentCP);
  532. SetFont(lpFnt, bpfdi);
  533. }
  534. } else {
  535. // Read the default INI information from the DOSAPP.INI file.
  536. // We only really use the information if we recognize the number of
  537. // WORDs read.
  538. iCount = GetIniWords(szDOSAPPSection, szDOSAPPDefault,
  539. (WORD*)&iiTemp, INI_WORDS, szDOSAPPINI);
  540. if (ISVALIDINI(iCount))
  541. CopyIniWordsToFntData(lpFnt, &iiTemp, iCount);
  542. // Try to read file-specific information. Note that any information
  543. // found will replace the information just read. We only really use
  544. // the information if we recognize the number of WORDs read.
  545. iCount = GetIniWords(szDOSAPPSection, ppl->szPathName,
  546. (WORD*)&iiTemp, INI_WORDS, szDOSAPPINI);
  547. if (ISVALIDINI(iCount))
  548. CopyIniWordsToFntData(lpFnt, &iiTemp, iCount);
  549. // If there is no font pool data (likely, if this is a 3.1 DOSAPP.INI),
  550. // then default to both raster and truetype.
  551. if (!(lpFnt->flFnt & FNT_BOTHFONTS))
  552. lpFnt->flFnt |= FNT_BOTHFONTS;
  553. }
  554. // Face names are taken from Frosting; the value stored in the PIF is
  555. // irrelevant.
  556. lstrcpyA(lpFnt->achRasterFaceName, szRasterFaceName);
  557. lstrcpyA(lpFnt->achTTFaceName, szTTFaceName[IsBilingualCP(lpFnt->wCurrentCP)? 1 : 0]);
  558. return sizeof(PROPFNT);
  559. }
  560. /*
  561. * INPUT
  562. * ppl -> property (assumes it is LOCKED)
  563. * lp386 -> 386 PIF data (NOT USED)
  564. * lpenh -> enhanced PIF data (GUARANTEED!)
  565. * lpFnt -> where to store font property data
  566. * cb = sizeof property data
  567. *
  568. * OUTPUT
  569. * # of bytes set
  570. */
  571. int SetFntData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPFNT lpFnt, int cb, UINT flOpt)
  572. {
  573. _LPENH_->fntProp = *lpFnt;
  574. ppl->flProp |= PROP_DIRTY;
  575. return sizeof(PROPFNT);
  576. }
  577. /*
  578. * INPUT
  579. * ppl -> property (assumes it is LOCKED)
  580. * lp386 -> 386 PIF data (NOT USED)
  581. * lpenh -> enhanced PIF data (may be NULL)
  582. * lpWin -> where to store window property data
  583. * cb = sizeof property data
  584. *
  585. * OUTPUT
  586. * # of bytes returned
  587. */
  588. int GetWinData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPWIN lpWin, int cb, UINT flOpt)
  589. {
  590. int iCount;
  591. INIINFO iiTemp;
  592. lpWin->flWin = flWinDefault;
  593. lpWin->wLength = PIF_WP_SIZE;
  594. if (_LPENH_) {
  595. *lpWin = _LPENH_->winProp;
  596. } else {
  597. // Read the default INI information from the DOSAPP.INI file.
  598. // We only really use the information if we recognize the number of
  599. // WORDs read.
  600. iCount = GetIniWords(szDOSAPPSection, szDOSAPPDefault,
  601. (WORD*)&iiTemp, INI_WORDS, szDOSAPPINI);
  602. if (ISVALIDINI(iCount))
  603. CopyIniWordsToWinData(lpWin, &iiTemp, iCount);
  604. // Try to read file-specific information. Note that any information
  605. // found will replace the information just read. We only really use
  606. // the information if we recognize the number of WORDs read.
  607. iCount = GetIniWords(szDOSAPPSection, ppl->szPathName,
  608. (WORD*)&iiTemp, INI_WORDS, szDOSAPPINI);
  609. if (ISVALIDINI(iCount))
  610. CopyIniWordsToWinData(lpWin, &iiTemp, iCount);
  611. }
  612. return sizeof(PROPWIN);
  613. }
  614. /** SetWinData - set window property data
  615. *
  616. * INPUT
  617. * ppl -> property (assumes it is LOCKED)
  618. * lp386 -> 386 PIF data (NOT USED)
  619. * lpenh -> enhanced PIF data (GUARANTEED!)
  620. * lpWin -> where to store window property data
  621. * cb = sizeof property data
  622. *
  623. * OUTPUT
  624. * # of bytes set
  625. */
  626. int SetWinData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPWIN lpWin, int cb, UINT flOpt)
  627. {
  628. _LPENH_->winProp = *lpWin;
  629. // In order to avoid excessive PIF creation, we will not set the
  630. // dirty bit on this particular call unless the properties were not
  631. // simply derived from internal defaults (no PIF file) or _DEFAULT.PIF.
  632. if (!(ppl->flProp & (PROP_NOPIF | PROP_DEFAULTPIF))) {
  633. ppl->flProp |= PROP_DIRTY;
  634. }
  635. return sizeof(PROPWIN);
  636. }
  637. /** GetEnvData - get environment property data
  638. *
  639. * INPUT
  640. * ppl -> property (assumes it is LOCKED)
  641. * lp386 -> 386 PIF data (NOT USED)
  642. * lpenh -> enhanced PIF data (may be NULL)
  643. * lpEnv -> where to store environment property data
  644. * cb = sizeof property data
  645. *
  646. * OUTPUT
  647. * # of bytes returned
  648. */
  649. int GetEnvData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPENV lpEnv, int cb, UINT flOpt)
  650. {
  651. BZero(lpEnv, sizeof(PROPENV));
  652. if (_LPENH_) {
  653. *lpEnv = _LPENH_->envProp;
  654. lpEnv->achBatchFile[ARRAYSIZE(lpEnv->achBatchFile)-1] = TEXT('\0');
  655. }
  656. if (!(flOpt & GETPROPS_OEM)) {
  657. /* Convert all strings from OEM character set to Ansi */
  658. CharToOemA(lpEnv->achBatchFile, lpEnv->achBatchFile);
  659. }
  660. return sizeof(PROPENV);
  661. }
  662. /** SetEnvData - set environment property data
  663. *
  664. * INPUT
  665. * ppl -> property (assumes it is LOCKED)
  666. * lp386 -> 386 PIF data (NOT USED)
  667. * lpenh -> enhanced PIF data (GUARANTEED!)
  668. * lpEnv -> where to store environment property data
  669. * cb = sizeof property data
  670. *
  671. * OUTPUT
  672. * # of bytes set
  673. */
  674. int SetEnvData(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPENV lpEnv, int cb, UINT flOpt)
  675. {
  676. _LPENH_->envProp = *lpEnv;
  677. _LPENH_->envProp.achBatchFile[ARRAYSIZE(_LPENH_->envProp.achBatchFile)-1] = TEXT('\0');
  678. if (!(flOpt & SETPROPS_OEM)) {
  679. /* Convert all strings from Ansi character set to OEM */
  680. CharToOemA(_LPENH_->envProp.achBatchFile, _LPENH_->envProp.achBatchFile);
  681. }
  682. ppl->flProp |= PROP_DIRTY;
  683. return sizeof(PROPENV);
  684. }
  685. /* INPUT
  686. * ppl -> property (assumes it is LOCKED)
  687. * lp386 -> 386 PIF data (NOT USED)
  688. * lpenh -> enhanced PIF data (may be NULL)
  689. * lpNt40 -> where to store NT/UNICODE property data
  690. * cb = sizeof property data
  691. *
  692. * OUTPUT
  693. * # of bytes returned
  694. */
  695. int GetNt40Data(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPNT40 lpnt40, int cb, UINT flOpt)
  696. {
  697. PROPPRG prg;
  698. WCHAR awchTmp[ MAX_PATH ];
  699. if (GetPrgData( ppl, aDataPtrs, &prg, sizeof(prg), flOpt) < sizeof(PROPPRG))
  700. return 0;
  701. if (!_LPWNT40_)
  702. return 0;
  703. lpnt40->flWnt = _LPWNT40_->nt40Prop.flWnt;
  704. // Initialize Command Line string
  705. if (lstrcmpA(prg.achCmdLine,_LPWNT40_->nt40Prop.achSaveCmdLine)==0) {
  706. lstrcpyA( lpnt40->achSaveCmdLine, _LPWNT40_->nt40Prop.achSaveCmdLine );
  707. ualstrcpy( lpnt40->awchCmdLine, _LPWNT40_->nt40Prop.awchCmdLine );
  708. } else {
  709. lstrcpyA( lpnt40->achSaveCmdLine, prg.achCmdLine );
  710. lstrcpyA( _LPWNT40_->nt40Prop.achSaveCmdLine, prg.achCmdLine );
  711. MultiByteToWideChar( CP_ACP, 0,
  712. prg.achCmdLine, -1,
  713. awchTmp, ARRAYSIZE(lpnt40->awchCmdLine)
  714. );
  715. awchTmp[ARRAYSIZE(lpnt40->awchCmdLine)-1] = TEXT('\0');
  716. ualstrcpy( lpnt40->awchCmdLine, awchTmp );
  717. ualstrcpy( _LPWNT40_->nt40Prop.awchCmdLine, lpnt40->awchCmdLine );
  718. }
  719. // Initialize Other File string
  720. if (lstrcmpA(prg.achOtherFile,_LPWNT40_->nt40Prop.achSaveOtherFile)==0) {
  721. lstrcpyA( lpnt40->achSaveOtherFile, _LPWNT40_->nt40Prop.achSaveOtherFile );
  722. ualstrcpy( lpnt40->awchOtherFile, _LPWNT40_->nt40Prop.awchOtherFile );
  723. } else {
  724. lstrcpyA( lpnt40->achSaveOtherFile, prg.achOtherFile );
  725. lstrcpyA( _LPWNT40_->nt40Prop.achSaveOtherFile, prg.achOtherFile );
  726. MultiByteToWideChar( CP_ACP, 0,
  727. prg.achOtherFile, -1,
  728. awchTmp, ARRAYSIZE(lpnt40->awchOtherFile)
  729. );
  730. awchTmp[ARRAYSIZE(lpnt40->awchOtherFile)-1] = TEXT('\0');
  731. ualstrcpy( lpnt40->awchOtherFile, awchTmp );
  732. ualstrcpy( _LPWNT40_->nt40Prop.awchOtherFile, lpnt40->awchOtherFile );
  733. }
  734. // Initialize PIF File string
  735. if (lstrcmpA(prg.achPIFFile,_LPWNT40_->nt40Prop.achSavePIFFile)==0) {
  736. lstrcpyA( lpnt40->achSavePIFFile, _LPWNT40_->nt40Prop.achSavePIFFile );
  737. ualstrcpy( lpnt40->awchPIFFile, _LPWNT40_->nt40Prop.awchPIFFile );
  738. } else {
  739. lstrcpyA( lpnt40->achSavePIFFile, prg.achPIFFile );
  740. lstrcpyA( _LPWNT40_->nt40Prop.achSavePIFFile, prg.achPIFFile );
  741. MultiByteToWideChar( CP_ACP, 0,
  742. prg.achPIFFile, -1,
  743. awchTmp, ARRAYSIZE(lpnt40->awchPIFFile)
  744. );
  745. awchTmp[ARRAYSIZE(lpnt40->awchPIFFile)-1] = TEXT('\0');
  746. ualstrcpy( lpnt40->awchPIFFile, awchTmp );
  747. ualstrcpy( _LPWNT40_->nt40Prop.awchPIFFile, lpnt40->awchPIFFile );
  748. }
  749. // Initialize Title string
  750. if (lstrcmpA(prg.achTitle,_LPWNT40_->nt40Prop.achSaveTitle)==0) {
  751. lstrcpyA( lpnt40->achSaveTitle, _LPWNT40_->nt40Prop.achSaveTitle );
  752. ualstrcpy( lpnt40->awchTitle, _LPWNT40_->nt40Prop.awchTitle );
  753. } else {
  754. lstrcpyA( lpnt40->achSaveTitle, prg.achTitle );
  755. lstrcpyA( _LPWNT40_->nt40Prop.achSaveTitle, prg.achTitle );
  756. MultiByteToWideChar( CP_ACP, 0,
  757. prg.achTitle, -1,
  758. awchTmp, ARRAYSIZE(lpnt40->awchTitle)
  759. );
  760. awchTmp[ARRAYSIZE(lpnt40->awchTitle)-1] = TEXT('\0');
  761. ualstrcpy( lpnt40->awchTitle, awchTmp );
  762. ualstrcpy( _LPWNT40_->nt40Prop.awchTitle, lpnt40->awchTitle );
  763. }
  764. // Initialize IconFile string
  765. if (lstrcmpA(prg.achIconFile,_LPWNT40_->nt40Prop.achSaveIconFile)==0) {
  766. lstrcpyA( lpnt40->achSaveIconFile, _LPWNT40_->nt40Prop.achSaveIconFile );
  767. ualstrcpy( lpnt40->awchIconFile, _LPWNT40_->nt40Prop.awchIconFile );
  768. } else {
  769. lstrcpyA( lpnt40->achSaveIconFile, prg.achIconFile );
  770. lstrcpyA( _LPWNT40_->nt40Prop.achSaveIconFile, prg.achIconFile );
  771. MultiByteToWideChar( CP_ACP, 0,
  772. prg.achIconFile, -1,
  773. awchTmp, ARRAYSIZE(lpnt40->awchIconFile)
  774. );
  775. awchTmp[ARRAYSIZE(lpnt40->awchIconFile)-1] = TEXT('\0');
  776. ualstrcpy( lpnt40->awchIconFile, awchTmp );
  777. ualstrcpy( _LPWNT40_->nt40Prop.awchIconFile, lpnt40->awchIconFile );
  778. }
  779. // Initialize Working Directory string
  780. if (lstrcmpA(prg.achWorkDir,_LPWNT40_->nt40Prop.achSaveWorkDir)==0) {
  781. lstrcpyA( lpnt40->achSaveWorkDir, _LPWNT40_->nt40Prop.achSaveWorkDir );
  782. ualstrcpy( lpnt40->awchWorkDir, _LPWNT40_->nt40Prop.awchWorkDir );
  783. } else {
  784. lstrcpyA( lpnt40->achSaveWorkDir, prg.achWorkDir );
  785. lstrcpyA( _LPWNT40_->nt40Prop.achSaveWorkDir, prg.achWorkDir );
  786. MultiByteToWideChar( CP_ACP, 0,
  787. prg.achWorkDir, -1,
  788. awchTmp, ARRAYSIZE(lpnt40->awchWorkDir)
  789. );
  790. awchTmp[ARRAYSIZE(lpnt40->awchWorkDir)-1] = TEXT('\0');
  791. ualstrcpy( lpnt40->awchWorkDir, awchTmp );
  792. ualstrcpy( _LPWNT40_->nt40Prop.awchWorkDir, lpnt40->awchWorkDir );
  793. }
  794. // Initialize Batch File string
  795. if (_LPENH_) {
  796. if (lstrcmpA(_LPENH_->envProp.achBatchFile,_LPWNT40_->nt40Prop.achSaveBatchFile)==0) {
  797. lstrcpyA( lpnt40->achSaveBatchFile, _LPWNT40_->nt40Prop.achSaveBatchFile );
  798. ualstrcpy( lpnt40->awchBatchFile, _LPWNT40_->nt40Prop.awchBatchFile );
  799. } else {
  800. lstrcpyA( lpnt40->achSaveBatchFile, _LPENH_->envProp.achBatchFile );
  801. lstrcpyA( _LPWNT40_->nt40Prop.achSaveBatchFile, _LPENH_->envProp.achBatchFile );
  802. MultiByteToWideChar( CP_ACP, 0,
  803. _LPENH_->envProp.achBatchFile, -1,
  804. awchTmp, ARRAYSIZE(lpnt40->awchBatchFile)
  805. );
  806. awchTmp[ARRAYSIZE(lpnt40->awchBatchFile)-1] = TEXT('\0');
  807. ualstrcpy( lpnt40->awchBatchFile, awchTmp );
  808. ualstrcpy( _LPWNT40_->nt40Prop.awchBatchFile, lpnt40->awchBatchFile );
  809. }
  810. } else {
  811. lpnt40->achSaveBatchFile[0] = '\0';
  812. _LPWNT40_->nt40Prop.achSaveBatchFile[0] = '\0';
  813. lpnt40->awchBatchFile[0] = TEXT('\0');
  814. _LPWNT40_->nt40Prop.awchBatchFile[0] = TEXT('\0');
  815. }
  816. // Initialize Console properties
  817. lpnt40->dwForeColor = _LPWNT40_->nt40Prop.dwForeColor;
  818. lpnt40->dwBackColor = _LPWNT40_->nt40Prop.dwBackColor;
  819. lpnt40->dwPopupForeColor = _LPWNT40_->nt40Prop.dwPopupForeColor;
  820. lpnt40->dwPopupBackColor = _LPWNT40_->nt40Prop.dwPopupBackColor;
  821. lpnt40->WinSize = _LPWNT40_->nt40Prop.WinSize;
  822. lpnt40->BuffSize = _LPWNT40_->nt40Prop.BuffSize;
  823. lpnt40->WinPos = _LPWNT40_->nt40Prop.WinPos;
  824. lpnt40->dwCursorSize = _LPWNT40_->nt40Prop.dwCursorSize;
  825. lpnt40->dwCmdHistBufSize = _LPWNT40_->nt40Prop.dwCmdHistBufSize;
  826. lpnt40->dwNumCmdHist = _LPWNT40_->nt40Prop.dwNumCmdHist;
  827. return sizeof(PROPNT40);
  828. }
  829. /*
  830. * INPUT
  831. * ppl -> property (assumes it is LOCKED)
  832. * lp386 -> 386 PIF data (NOT USED)
  833. * lpenh -> enhanced PIF data (GUARANTEED!)
  834. * lpWnt -> where to store NT/UNICODE property data
  835. * cb = sizeof property data
  836. *
  837. * OUTPUT
  838. * # of bytes set
  839. */
  840. int SetNt40Data(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPNT40 lpnt40, int cb, UINT flOpt)
  841. {
  842. _LPWNT40_->nt40Prop.flWnt = lpnt40->flWnt;
  843. // Set Command Line string
  844. lstrcpyA( _LPWNT40_->nt40Prop.achSaveCmdLine, lpnt40->achSaveCmdLine );
  845. ualstrcpy( _LPWNT40_->nt40Prop.awchCmdLine, lpnt40->awchCmdLine );
  846. // Set Other File string
  847. lstrcpyA( _LPWNT40_->nt40Prop.achSaveOtherFile, lpnt40->achSaveOtherFile );
  848. ualstrcpy( _LPWNT40_->nt40Prop.awchOtherFile, lpnt40->awchOtherFile );
  849. // Set PIF File string
  850. lstrcpyA( _LPWNT40_->nt40Prop.achSavePIFFile, lpnt40->achSavePIFFile );
  851. ualstrcpy( _LPWNT40_->nt40Prop.awchPIFFile, lpnt40->awchPIFFile );
  852. // Set Title string
  853. lstrcpyA( _LPWNT40_->nt40Prop.achSaveTitle, lpnt40->achSaveTitle );
  854. ualstrcpy( _LPWNT40_->nt40Prop.awchTitle, lpnt40->awchTitle );
  855. // Set IconFile string
  856. lstrcpyA( _LPWNT40_->nt40Prop.achSaveIconFile, lpnt40->achSaveIconFile );
  857. ualstrcpy( _LPWNT40_->nt40Prop.awchIconFile, lpnt40->awchIconFile );
  858. // Set Working Directory string
  859. lstrcpyA( _LPWNT40_->nt40Prop.achSaveWorkDir, lpnt40->achSaveWorkDir );
  860. ualstrcpy( _LPWNT40_->nt40Prop.awchWorkDir, lpnt40->awchWorkDir );
  861. // Set Batch File string
  862. lstrcpyA( _LPWNT40_->nt40Prop.achSaveBatchFile, lpnt40->achSaveBatchFile );
  863. ualstrcpy( _LPWNT40_->nt40Prop.awchBatchFile, lpnt40->awchBatchFile );
  864. // Set Console properties
  865. _LPWNT40_->nt40Prop.dwForeColor = lpnt40->dwForeColor;
  866. _LPWNT40_->nt40Prop.dwBackColor = lpnt40->dwBackColor;
  867. _LPWNT40_->nt40Prop.dwPopupForeColor = lpnt40->dwPopupForeColor;
  868. _LPWNT40_->nt40Prop.dwPopupBackColor = lpnt40->dwPopupBackColor;
  869. _LPWNT40_->nt40Prop.WinSize = lpnt40->WinSize;
  870. _LPWNT40_->nt40Prop.BuffSize = lpnt40->BuffSize;
  871. _LPWNT40_->nt40Prop.WinPos = lpnt40->WinPos;
  872. _LPWNT40_->nt40Prop.dwCursorSize = lpnt40->dwCursorSize;
  873. _LPWNT40_->nt40Prop.dwCmdHistBufSize = lpnt40->dwCmdHistBufSize;
  874. _LPWNT40_->nt40Prop.dwNumCmdHist = lpnt40->dwNumCmdHist;
  875. ppl->flProp |= PROP_DIRTY;
  876. return sizeof(PROPNT40);
  877. }
  878. /*
  879. * INPUT
  880. * ppl -> property (assumes it is LOCKED)
  881. * lp386 -> 386 PIF data (NOT USED)
  882. * lpenh -> enhanced PIF data (GUARANTEED!)
  883. * lpNt31 -> where to store NT/UNICODE property data
  884. * cb = sizeof property data
  885. *
  886. * OUTPUT
  887. * # of bytes set
  888. */
  889. int GetNt31Data(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPNT31 lpnt31, int cb, UINT flOpt)
  890. {
  891. lpnt31->dwWNTFlags = _LPWNT31_->nt31Prop.dwWNTFlags;
  892. lpnt31->dwRes1 = _LPWNT31_->nt31Prop.dwRes1;
  893. lpnt31->dwRes2 = _LPWNT31_->nt31Prop.dwRes2;
  894. // Set Config.sys file string
  895. lstrcpyA( lpnt31->achConfigFile, _LPWNT31_->nt31Prop.achConfigFile );
  896. // Set Autoexec.bat file string
  897. lstrcpyA( lpnt31->achAutoexecFile, _LPWNT31_->nt31Prop.achAutoexecFile );
  898. return sizeof(PROPNT31);
  899. }
  900. /** SetNt31Data - set environment property data
  901. *
  902. * INPUT
  903. * ppl -> property (assumes it is LOCKED)
  904. * lp386 -> 386 PIF data (NOT USED)
  905. * lpenh -> enhanced PIF data (GUARANTEED!)
  906. * lpNt31 -> where to store NT/UNICODE property data
  907. * cb = sizeof property data
  908. *
  909. * OUTPUT
  910. * # of bytes set
  911. */
  912. int SetNt31Data(PPROPLINK ppl, DATAPTRS aDataPtrs, LPPROPNT31 lpnt31, int cb, UINT flOpt)
  913. {
  914. _LPWNT31_->nt31Prop.dwWNTFlags = lpnt31->dwWNTFlags;
  915. _LPWNT31_->nt31Prop.dwRes1 = lpnt31->dwRes1;
  916. _LPWNT31_->nt31Prop.dwRes2 = lpnt31->dwRes2;
  917. // Set Config.sys file string
  918. lstrcpyA( _LPWNT31_->nt31Prop.achConfigFile, lpnt31->achConfigFile );
  919. // Set Autoexec.bat file string
  920. lstrcpyA( _LPWNT31_->nt31Prop.achAutoexecFile, lpnt31->achAutoexecFile );
  921. ppl->flProp |= PROP_DIRTY;
  922. return sizeof(PROPNT31);
  923. }
  924. /** CopyIniWordsToFntData
  925. *
  926. * Transfer INIINFO data to PROPFNT structure.
  927. *
  928. * Entry:
  929. * lpFnt -> PROPFNT
  930. * lpii -> INIINFO
  931. * cWords == # of INIINFO words available
  932. *
  933. * Exit:
  934. * Nothing
  935. */
  936. void CopyIniWordsToFntData(LPPROPFNT lpFnt, LPINIINFO lpii, int cWords)
  937. {
  938. lpFnt->flFnt = (lpii->wFlags & FNT_BOTHFONTS);
  939. // cWords is transformed into cBytes (only the name is the same...)
  940. cWords *= 2;
  941. if (cWords > FIELD_OFFSET(INIINFO, wFontHeight)) {
  942. // Note that we can set both the desired and ACTUAL fields to
  943. // the same thing, because in 3.1, only raster fonts were supported.
  944. lpFnt->flFnt |= FNT_RASTER;
  945. lpFnt->cxFont = lpFnt->cxFontActual = lpii->wFontWidth;
  946. lpFnt->cyFont = lpFnt->cyFontActual = lpii->wFontHeight;
  947. }
  948. }
  949. /*
  950. * Transfer INIINFO data to PROPWIN structure.
  951. *
  952. * Entry:
  953. * lpWin -> PROPWIN
  954. * lpii -> INIINFO
  955. * cWords == # of INIINFO words available
  956. *
  957. * Exit:
  958. * Nothing
  959. */
  960. void CopyIniWordsToWinData(LPPROPWIN lpWin, LPINIINFO lpii, int cWords)
  961. {
  962. lpWin->flWin = lpii->wFlags & (WIN_SAVESETTINGS | WIN_TOOLBAR);
  963. // The new NORESTORE bit's setting should be the opposite
  964. // the user's SAVESETTINGS bit
  965. lpWin->flWinInit &= ~WININIT_NORESTORE;
  966. if (!(lpWin->flWin & WIN_SAVESETTINGS))
  967. lpWin->flWinInit |= WININIT_NORESTORE;
  968. // cWords is transformed into cBytes (only the name is the same...)
  969. cWords *= 2;
  970. if (cWords > FIELD_OFFSET(INIINFO,wWinWidth))
  971. memcpy(&lpWin->cxWindow, &lpii->wWinWidth,
  972. min(cWords-FIELD_OFFSET(INIINFO,wWinWidth),
  973. sizeof(INIINFO)-FIELD_OFFSET(INIINFO,wWinWidth)));
  974. }
  975. /** GetIniWords
  976. *
  977. * Reads a sequence of WORDs or SHORTs from a specified section
  978. * of an INI file into a supplied array.
  979. *
  980. * Entry:
  981. * lpszSection -> section name (major key)
  982. * lpszEntry -> entry name (minor key)
  983. * lpwBuf -> array of WORDs to receive data
  984. * cwBuf = size of lpwBuf
  985. * lpszFilename -> name of INI file to inspect
  986. *
  987. * Exit:
  988. * Returns number of words read, 0 on error.
  989. *
  990. * Overview:
  991. * Grab the string via GetPrivateProfileString, then manually
  992. * parse the numbers out of it.
  993. */
  994. WORD GetIniWords(LPCTSTR lpszSection, LPCTSTR lpszEntry,
  995. LPWORD lpwBuf, WORD cwBuf, LPCTSTR lpszFilename)
  996. {
  997. TCHAR szBuffer[MAX_INI_BUFFER];
  998. // Read the profile entry as a string
  999. if (!GetPrivateProfileString(lpszSection, lpszEntry,
  1000. c_szNULL, szBuffer, ARRAYSIZE(szBuffer),
  1001. lpszFilename))
  1002. return 0;
  1003. return ParseIniWords(szBuffer, lpwBuf, cwBuf, NULL);
  1004. }
  1005. /* Reads a sequence of WORDs or SHORTs from a LPSTR into a
  1006. * supplied array.
  1007. *
  1008. * Entry:
  1009. * lpsz -> string to parse
  1010. * lpwBuf -> array of WORDs to receive data
  1011. * cwBuf == size of lpwBuf
  1012. * lppsz -> optional pointer for address of first unscanned character
  1013. *
  1014. * Exit:
  1015. * Returns number of words read, 0 on error.
  1016. */
  1017. WORD ParseIniWords(LPCTSTR lpsz, LPWORD lpwBuf, WORD cwBuf, LPTSTR *lplpsz)
  1018. {
  1019. WORD wCount = 0;
  1020. for (; cwBuf; --cwBuf) {
  1021. while (*lpsz == TEXT(' ') || *lpsz == TEXT('\t') || *lpsz == TEXT(','))
  1022. ++lpsz;
  1023. if (!*lpsz)
  1024. break; // end of string reached
  1025. *lpwBuf++ = (WORD) StrToInt(lpsz);
  1026. ++wCount;
  1027. while (*lpsz == TEXT('-') || *lpsz >= TEXT('0') && *lpsz <= TEXT('9'))
  1028. ++lpsz;
  1029. }
  1030. if (lplpsz)
  1031. *lplpsz = (LPTSTR)lpsz;
  1032. return wCount;
  1033. }
  1034. /* Given an array of words, write them out to an INI file in a manner
  1035. * that GetIniWords can read back.
  1036. *
  1037. * Entry:
  1038. * lpszSection -> section name (major key)
  1039. * lpszEntry -> entry name (minor key)
  1040. * lpwBuf -> array of WORDs to write
  1041. * cwBuf = size of lpwBuf, may not exceed MAXINIWORDS
  1042. * lpszFilename -> name of INI file to write to
  1043. *
  1044. * Exit:
  1045. * Returns nonzero on success.
  1046. *
  1047. * Overview:
  1048. * Build a giant string consisting of the WORDs glommed together
  1049. * (separated by spaces) and write it out via WritePrivateProfileString.
  1050. */
  1051. BOOL WriteIniWords(LPCTSTR lpszSection, LPCTSTR lpszEntry,
  1052. LPCWORD lpwBuf, WORD cwBuf, LPCTSTR lpszFilename)
  1053. {
  1054. LPTSTR lpsz;
  1055. TCHAR szBuffer[MAX_INI_BUFFER];
  1056. for (lpsz = szBuffer; cwBuf; --cwBuf)
  1057. lpsz += wsprintf(lpsz, TEXT("%d "), *lpwBuf++);
  1058. return WritePrivateProfileString(lpszSection, lpszEntry, szBuffer, lpszFilename);
  1059. }