Leaked source code of windows server 2003
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.

1388 lines
47 KiB

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