MRU.CPP 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #include "../../idlib/precompiled.h"
  21. #pragma hdrstop
  22. #include <windowsx.h>
  23. #include "mru.h"
  24. //*************************************************************
  25. // File name: mru.c
  26. //
  27. // Description:
  28. //
  29. // Routines for MRU support
  30. //
  31. // Development Team:
  32. //
  33. // Gilles Vollant (100144.2636@compuserve.com)
  34. //
  35. //*************************************************************
  36. // CreateMruMenu : MRUMENU constructor
  37. // wNbLruShowInit : nb of item showed in menu
  38. // wNbLruMenuInit : nb of item stored in memory
  39. // wMaxSizeLruItemInit : size max. of filename
  40. //*************************************************************
  41. //
  42. // CreateMruMenu()
  43. //
  44. // Purpose:
  45. //
  46. // Allocate and Initialize an MRU and return a pointer on it
  47. //
  48. //
  49. // Parameters:
  50. //
  51. // WORD wNbLruShowInit - Maximum number of item displayed on menu
  52. // WORD wNbLruMenuInit - Maximum number of item stored in memory
  53. // WORD wMaxSizeLruItemInit - Maximum size of an item (ie size of pathname)
  54. // WORD wIdMruInit - ID of the first item in the menu (default:IDMRU)
  55. //
  56. //
  57. // Return: (LPMRUMENU)
  58. //
  59. // Pointer on a MRUMENU structure, used by other function
  60. //
  61. //
  62. // Comments:
  63. // wNbLruShowInit <= wNbLruMenuInit
  64. //
  65. //
  66. // History: Date Author Comment
  67. // 09/24/94 G. Vollant Created
  68. //
  69. //*************************************************************
  70. LPMRUMENU CreateMruMenu (WORD wNbLruShowInit,
  71. WORD wNbLruMenuInit,WORD wMaxSizeLruItemInit,WORD wIdMruInit)
  72. {
  73. LPMRUMENU lpMruMenu;
  74. lpMruMenu = (LPMRUMENU)GlobalAllocPtr(GHND,sizeof(MRUMENU));
  75. lpMruMenu->wNbItemFill = 0;
  76. lpMruMenu->wNbLruMenu = wNbLruMenuInit;
  77. lpMruMenu->wNbLruShow = wNbLruShowInit;
  78. lpMruMenu->wIdMru = wIdMruInit;
  79. lpMruMenu->wMaxSizeLruItem = wMaxSizeLruItemInit;
  80. lpMruMenu->lpMRU = (LPSTR)GlobalAllocPtr(GHND,
  81. lpMruMenu->wNbLruMenu*(UINT)lpMruMenu->wMaxSizeLruItem);
  82. if (lpMruMenu->lpMRU == NULL)
  83. {
  84. GlobalFreePtr(lpMruMenu);
  85. lpMruMenu = NULL;
  86. }
  87. return lpMruMenu;
  88. }
  89. //*************************************************************
  90. //
  91. // CreateMruMenuDefault()
  92. //
  93. // Purpose:
  94. //
  95. // Allocate and Initialize an MRU and return a pointer on it
  96. // Use default parameter
  97. //
  98. //
  99. // Parameters:
  100. //
  101. //
  102. // Return: (LPMRUMENU)
  103. //
  104. // Pointer on a MRUMENU structure, used by other function
  105. //
  106. //
  107. // Comments:
  108. //
  109. //
  110. // History: Date Author Comment
  111. // 09/24/94 G. Vollant Created
  112. //
  113. //*************************************************************
  114. LPMRUMENU CreateMruMenuDefault()
  115. {
  116. return CreateMruMenu (NBMRUMENUSHOW,NBMRUMENU,MAXSIZEMRUITEM,IDMRU);
  117. }
  118. //*************************************************************
  119. //
  120. // DeleteMruMenu()
  121. //
  122. // Purpose:
  123. // Destructor :
  124. // Clean and free a MRUMENU structure
  125. //
  126. // Parameters:
  127. //
  128. // LPMRUMENU lpMruMenu - pointer on MRUMENU, allocated
  129. // by CreateMruMenu() or CreateMruMenuDefault()
  130. //
  131. //
  132. // Return: void
  133. //
  134. //
  135. // Comments:
  136. //
  137. //
  138. // History: Date Author Comment
  139. // 09/24/94 G. Vollant Created
  140. //
  141. //*************************************************************
  142. void DeleteMruMenu(LPMRUMENU lpMruMenu)
  143. {
  144. GlobalFreePtr(lpMruMenu->lpMRU);
  145. GlobalFreePtr(lpMruMenu);
  146. }
  147. //*************************************************************
  148. //
  149. // SetNbLruShow()
  150. //
  151. // Purpose:
  152. // Change the maximum number of item displayed on menu
  153. //
  154. // Parameters:
  155. // LPMRUMENU lpMruMenu - pointer on MRUMENU
  156. // WORD wNbLruShowInit - Maximum number of item displayed on menu
  157. //
  158. //
  159. // Return: void
  160. //
  161. //
  162. // Comments:
  163. //
  164. //
  165. // History: Date Author Comment
  166. // 09/24/94 G. Vollant Created
  167. //
  168. //*************************************************************
  169. void SetNbLruShow (LPMRUMENU lpMruMenu,WORD wNbLruShowInit)
  170. {
  171. lpMruMenu->wNbLruShow = min(wNbLruShowInit,lpMruMenu->wNbLruMenu);
  172. }
  173. //*************************************************************
  174. //
  175. // SetMenuItem()
  176. //
  177. // Purpose:
  178. // Set the filename of an item
  179. //
  180. // Parameters:
  181. // LPMRUMENU lpMruMenu - pointer on MRUMENU
  182. // WORD wItem - Number of Item to set, zero based
  183. // LPSTR lpItem - String, contain the filename of the item
  184. //
  185. //
  186. // Return: (BOOL)
  187. // TRUE - Function run successfully
  188. // FALSE - Function don't run successfully
  189. //
  190. //
  191. // Comments:
  192. // used when load .INI or reg database
  193. //
  194. // History: Date Author Comment
  195. // 09/24/94 G. Vollant Created
  196. //
  197. //*************************************************************
  198. BOOL SetMenuItem (LPMRUMENU lpMruMenu,WORD wItem,LPSTR lpItem)
  199. {
  200. if (wItem >= NBMRUMENU)
  201. return FALSE;
  202. _fstrncpy((lpMruMenu->lpMRU) +
  203. ((lpMruMenu->wMaxSizeLruItem) * (UINT)wItem),
  204. lpItem,lpMruMenu->wMaxSizeLruItem-1);
  205. lpMruMenu->wNbItemFill = max(lpMruMenu->wNbItemFill,wItem+1);
  206. return TRUE;
  207. }
  208. //*************************************************************
  209. //
  210. // GetMenuItem()
  211. //
  212. // Purpose:
  213. // Get the filename of an item
  214. //
  215. // Parameters:
  216. // LPMRUMENU lpMruMenu - pointer on MRUMENU
  217. // WORD wItem - Number of Item to set, zero based
  218. // BOOL fIDMBased - TRUE : wItem is based on ID menu item
  219. // FALSE : wItem is zero-based
  220. // LPSTR lpItem - String where the filename of the item will be
  221. // stored by GetMenuItem()
  222. // UINT uiSize - Size of the lpItem buffer
  223. //
  224. //
  225. // Return: (BOOL)
  226. // TRUE - Function run successfully
  227. // FALSE - Function don't run successfully
  228. //
  229. //
  230. // Comments:
  231. // Used for saving in .INI or reg database, or when user select
  232. // an MRU in File menu
  233. //
  234. // History: Date Author Comment
  235. // 09/24/94 G. Vollant Created
  236. //
  237. //*************************************************************
  238. BOOL GetMenuItem (LPMRUMENU lpMruMenu,WORD wItem,
  239. BOOL fIDMBased,LPSTR lpItem,UINT uiSize)
  240. {
  241. if (fIDMBased)
  242. wItem -= (lpMruMenu->wIdMru + 1);
  243. if (wItem >= lpMruMenu->wNbItemFill)
  244. return FALSE;
  245. _fstrncpy(lpItem,(lpMruMenu->lpMRU) +
  246. ((lpMruMenu->wMaxSizeLruItem) * (UINT)(wItem)),uiSize);
  247. *(lpItem+uiSize-1) = '\0';
  248. return TRUE;
  249. }
  250. //*************************************************************
  251. //
  252. // AddNewItem()
  253. //
  254. // Purpose:
  255. // Add an item at the begin of the list
  256. //
  257. // Parameters:
  258. // LPMRUMENU lpMruMenu - pointer on MRUMENU
  259. // LPSTR lpItem - String contain the filename to add
  260. //
  261. // Return: (BOOL)
  262. // TRUE - Function run successfully
  263. // FALSE - Function don't run successfully
  264. //
  265. //
  266. // Comments:
  267. // Used when used open a file (using File Open common
  268. // dialog, Drag and drop or MRU)
  269. //
  270. // History: Date Author Comment
  271. // 09/24/94 G. Vollant Created
  272. //
  273. //*************************************************************
  274. void AddNewItem (LPMRUMENU lpMruMenu,LPSTR lpItem)
  275. {
  276. WORD i,j;
  277. for (i=0;i<lpMruMenu->wNbItemFill;i++)
  278. if (lstrcmpi(lpItem,(lpMruMenu->lpMRU) +
  279. ((lpMruMenu->wMaxSizeLruItem) * (UINT)i)) == 0)
  280. {
  281. // Shift the other items
  282. for (j=i;j>0;j--)
  283. lstrcpy((lpMruMenu->lpMRU) + (lpMruMenu->wMaxSizeLruItem * (UINT)j),
  284. (lpMruMenu->lpMRU) + (lpMruMenu->wMaxSizeLruItem * (UINT)(j-1)));
  285. _fstrncpy(lpMruMenu->lpMRU,lpItem,lpMruMenu->wMaxSizeLruItem-1);
  286. return ;
  287. }
  288. lpMruMenu->wNbItemFill = min(lpMruMenu->wNbItemFill+1,lpMruMenu->wNbLruMenu);
  289. for (i=lpMruMenu->wNbItemFill-1;i>0;i--)
  290. lstrcpy(lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)i),
  291. lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)(i-1)));
  292. _fstrncpy(lpMruMenu->lpMRU,lpItem,lpMruMenu->wMaxSizeLruItem-1);
  293. }
  294. //*************************************************************
  295. //
  296. // DelMenuItem()
  297. //
  298. // Purpose:
  299. // Delete an item
  300. //
  301. // Parameters:
  302. // LPMRUMENU lpMruMenu - pointer on MRUMENU
  303. // WORD wItem - Number of Item to set, zero based
  304. // BOOL fIDMBased - TRUE : wItem is based on ID menu item
  305. // FALSE : wItem is zero-based
  306. //
  307. // Return: (BOOL)
  308. // TRUE - Function run successfully
  309. // FALSE - Function don't run successfully
  310. //
  311. //
  312. // Comments:
  313. // Used when used open a file, using MRU, and when an error
  314. // occured (by example, when file was deleted)
  315. //
  316. // History: Date Author Comment
  317. // 09/24/94 G. Vollant Created
  318. //
  319. //*************************************************************
  320. BOOL DelMenuItem(LPMRUMENU lpMruMenu,WORD wItem,BOOL fIDMBased)
  321. {
  322. WORD i;
  323. if (fIDMBased)
  324. wItem -= (lpMruMenu->wIdMru + 1);
  325. if (lpMruMenu->wNbItemFill <= wItem)
  326. return FALSE;
  327. lpMruMenu->wNbItemFill--;
  328. for (i=wItem;i<lpMruMenu->wNbItemFill;i++)
  329. lstrcpy(lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)i),
  330. lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem * (UINT)(i+1)));
  331. return TRUE;
  332. }
  333. //*************************************************************
  334. //
  335. // PlaceMenuMRUItem()
  336. //
  337. // Purpose:
  338. // Add MRU at the end of a menu
  339. //
  340. // Parameters:
  341. // LPMRUMENU lpMruMenu - pointer on MRUMENU
  342. // HMENU hMenu - Handle of menu where MRU must be added
  343. // UINT uiItem - Item of menu entry where MRU must be added
  344. //
  345. // Return: void
  346. //
  347. //
  348. // Comments:
  349. // Used MRU is modified, for refresh the File menu
  350. //
  351. // History: Date Author Comment
  352. // 09/24/94 G. Vollant Created
  353. //
  354. //*************************************************************
  355. void PlaceMenuMRUItem(LPMRUMENU lpMruMenu,HMENU hMenu,UINT uiItem)
  356. {
  357. int i;
  358. WORD wNbShow;
  359. if (hMenu == NULL)
  360. return;
  361. // remove old MRU in menu
  362. for (i=0;i<=(int)(lpMruMenu->wNbLruMenu);i++)
  363. RemoveMenu(hMenu,i+lpMruMenu->wIdMru,MF_BYCOMMAND);
  364. if (lpMruMenu->wNbItemFill == 0)
  365. return;
  366. // If they are item, insert a separator before the files
  367. InsertMenu(hMenu,uiItem,MF_SEPARATOR,lpMruMenu->wIdMru,NULL);
  368. wNbShow = min(lpMruMenu->wNbItemFill,lpMruMenu->wNbLruShow);
  369. for (i=(int)wNbShow-1;i>=0;i--)
  370. {
  371. LPSTR lpTxt;
  372. if (lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20))
  373. {
  374. wsprintf(lpTxt,"&%lu %s",
  375. (DWORD)(i+1),lpMruMenu->lpMRU + (lpMruMenu->wMaxSizeLruItem*(UINT)i));
  376. InsertMenu(hMenu,(((WORD)i)!=(wNbShow-1)) ? (lpMruMenu->wIdMru+i+2) : lpMruMenu->wIdMru,
  377. MF_STRING,lpMruMenu->wIdMru+i+1,lpTxt);
  378. GlobalFreePtr(lpTxt);
  379. }
  380. }
  381. }
  382. ///////////////////////////////////////////
  383. //*************************************************************
  384. //
  385. // SaveMruInIni()
  386. //
  387. // Purpose:
  388. // Save MRU in a private .INI
  389. //
  390. // Parameters:
  391. // LPMRUMENU lpMruMenu - pointer on MRUMENU
  392. // LPSTR lpszSection - Points to a null-terminated string containing
  393. // the name of the section
  394. // LPSTR lpszFile - Points to a null-terminated string that names
  395. // the initialization file.
  396. //
  397. // Return: (BOOL)
  398. // TRUE - Function run successfully
  399. // FALSE - Function don't run successfully
  400. //
  401. //
  402. // Comments:
  403. // See WritePrivateProfileString API for more info on lpszSection and lpszFile
  404. //
  405. // History: Date Author Comment
  406. // 09/24/94 G. Vollant Created
  407. //
  408. //*************************************************************
  409. BOOL SaveMruInIni(LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile)
  410. {
  411. LPSTR lpTxt;
  412. WORD i;
  413. lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20);
  414. if (lpTxt == NULL)
  415. return FALSE;
  416. for (i=0;i<lpMruMenu->wNbLruMenu;i++)
  417. {
  418. char szEntry[16];
  419. wsprintf(szEntry,"File%lu",(DWORD)i+1);
  420. if (!GetMenuItem(lpMruMenu,i,FALSE,lpTxt,lpMruMenu->wMaxSizeLruItem + 10))
  421. *lpTxt = '\0';
  422. WritePrivateProfileString(lpszSection,szEntry,lpTxt,lpszFile);
  423. }
  424. GlobalFreePtr(lpTxt);
  425. WritePrivateProfileString(NULL,NULL,NULL,lpszFile); // flush cache
  426. return TRUE;
  427. }
  428. //*************************************************************
  429. //
  430. // LoadMruInIni()
  431. //
  432. // Purpose:
  433. // Load MRU from a private .INI
  434. //
  435. // Parameters:
  436. // LPMRUMENU lpMruMenu - pointer on MRUMENU
  437. // LPSTR lpszSection - Points to a null-terminated string containing
  438. // the name of the section
  439. // LPSTR lpszFile - Points to a null-terminated string that names
  440. // the initialization file.
  441. //
  442. // Return: (BOOL)
  443. // TRUE - Function run successfully
  444. // FALSE - Function don't run successfully
  445. //
  446. //
  447. // Comments:
  448. // See GetPrivateProfileString API for more info on lpszSection and lpszFile
  449. //
  450. // History: Date Author Comment
  451. // 09/24/94 G. Vollant Created
  452. //
  453. //*************************************************************
  454. BOOL LoadMruInIni(LPMRUMENU lpMruMenu,LPSTR lpszSection,LPSTR lpszFile)
  455. {
  456. LPSTR lpTxt;
  457. WORD i;
  458. lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20);
  459. if (lpTxt == NULL)
  460. return FALSE;
  461. for (i=0;i<lpMruMenu->wNbLruMenu;i++)
  462. {
  463. char szEntry[16];
  464. wsprintf(szEntry,"File%lu",(DWORD)i+1);
  465. GetPrivateProfileString(lpszSection,szEntry,"",lpTxt,
  466. lpMruMenu->wMaxSizeLruItem + 10,lpszFile);
  467. if (*lpTxt == '\0')
  468. break;
  469. SetMenuItem(lpMruMenu,i,lpTxt);
  470. }
  471. GlobalFreePtr(lpTxt);
  472. return TRUE;
  473. }
  474. #ifdef WIN32
  475. BOOL IsWin395OrHigher(void)
  476. {
  477. WORD wVer;
  478. wVer = LOWORD(GetVersion());
  479. wVer = (((WORD)LOBYTE(wVer)) << 8) | (WORD)HIBYTE(wVer);
  480. return (wVer >= 0x035F); // 5F = 95 dec
  481. }
  482. //*************************************************************
  483. //
  484. // SaveMruInReg()
  485. //
  486. // Purpose:
  487. // Save MRU in the registry
  488. //
  489. // Parameters:
  490. // LPMRUMENU lpMruMenu - pointer on MRUMENU
  491. // LPSTR lpszKey - Points to a null-terminated string
  492. // specifying the name of a key that
  493. // this function opens or creates.
  494. //
  495. // Return: (BOOL)
  496. // TRUE - Function run successfully
  497. // FALSE - Function don't run successfully
  498. //
  499. //
  500. // Comments:
  501. // Win32 function designed for Windows NT and Windows 95
  502. // See RegCreateKeyEx API for more info on lpszKey
  503. //
  504. // History: Date Author Comment
  505. // 09/24/94 G. Vollant Created
  506. //
  507. //*************************************************************
  508. BOOL SaveMruInReg(LPMRUMENU lpMruMenu,LPSTR lpszKey)
  509. {
  510. LPSTR lpTxt;
  511. WORD i;
  512. HKEY hCurKey;
  513. DWORD dwDisp;
  514. lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20);
  515. if (lpTxt == NULL)
  516. return FALSE;
  517. RegCreateKeyEx(HKEY_CURRENT_USER,lpszKey,0,NULL,
  518. REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hCurKey,&dwDisp);
  519. for (i=0;i<lpMruMenu->wNbLruMenu;i++)
  520. {
  521. char szEntry[16];
  522. wsprintf(szEntry,"File%lu",(DWORD)i+1);
  523. if (!GetMenuItem(lpMruMenu,i,FALSE,lpTxt,lpMruMenu->wMaxSizeLruItem + 10))
  524. *lpTxt = '\0';
  525. RegSetValueEx(hCurKey,szEntry,0,REG_SZ,(unsigned char*)lpTxt,lstrlen(lpTxt));
  526. }
  527. RegCloseKey(hCurKey);
  528. GlobalFreePtr(lpTxt);
  529. return TRUE;
  530. }
  531. //*************************************************************
  532. //
  533. // LoadMruInReg()
  534. //
  535. // Purpose:
  536. // Load MRU from the registry
  537. //
  538. // Parameters:
  539. // LPMRUMENU lpMruMenu - pointer on MRUMENU
  540. // LPSTR lpszKey - Points to a null-terminated string
  541. // specifying the name of a key that
  542. // this function opens or creates.
  543. //
  544. // Return: (BOOL)
  545. // TRUE - Function run successfully
  546. // FALSE - Function don't run successfully
  547. //
  548. //
  549. // Comments:
  550. // Win32 function designed for Windows NT and Windows 95
  551. // See RegOpenKeyEx API for more info on lpszKey
  552. //
  553. // History: Date Author Comment
  554. // 09/24/94 G. Vollant Created
  555. //
  556. //*************************************************************
  557. BOOL LoadMruInReg(LPMRUMENU lpMruMenu,LPSTR lpszKey)
  558. {
  559. LPSTR lpTxt;
  560. WORD i;
  561. HKEY hCurKey;
  562. DWORD dwType;
  563. lpTxt = (LPSTR)GlobalAllocPtr(GHND,lpMruMenu->wMaxSizeLruItem + 20);
  564. if (lpTxt == NULL)
  565. return FALSE;
  566. RegOpenKeyEx(HKEY_CURRENT_USER,lpszKey,0,KEY_READ,&hCurKey);
  567. for (i=0;i<lpMruMenu->wNbLruMenu;i++)
  568. {
  569. char szEntry[16];
  570. DWORD dwSizeBuf;
  571. wsprintf(szEntry,"File%lu",(DWORD)i+1);
  572. *lpTxt = '\0';
  573. dwSizeBuf = lpMruMenu->wMaxSizeLruItem + 10;
  574. RegQueryValueEx(hCurKey,szEntry,NULL,&dwType,(LPBYTE)lpTxt,&dwSizeBuf);
  575. *(lpTxt+dwSizeBuf)='\0';
  576. if (*lpTxt == '\0')
  577. break;
  578. SetMenuItem(lpMruMenu,i,lpTxt);
  579. }
  580. RegCloseKey(hCurKey);
  581. GlobalFreePtr(lpTxt);
  582. return TRUE;
  583. }
  584. //*************************************************************
  585. //
  586. // GetWin32Kind()
  587. //
  588. // Purpose:
  589. // Get the Win32 platform
  590. //
  591. // Parameters:
  592. //
  593. // Return: (WIN32KIND)
  594. // WINNT - Run under Windows NT
  595. // WIN32S - Run under Windows 3.1x + Win32s
  596. // WIN95ORGREATHER - Run under Windows 95
  597. //
  598. //
  599. // Comments:
  600. // Win32 function designed for Windows NT and Windows 95
  601. // See RegOpenKeyEx API for more info on lpszKey
  602. //
  603. // History: Date Author Comment
  604. // 09/24/94 G. Vollant Created
  605. //
  606. //*************************************************************
  607. WIN32KIND GetWin32Kind()
  608. {
  609. BOOL IsWin395OrHigher(void);
  610. WORD wVer;
  611. if ((GetVersion() & 0x80000000) == 0)
  612. return WINNT;
  613. wVer = LOWORD(GetVersion());
  614. wVer = (((WORD)LOBYTE(wVer)) << 8) | (WORD)HIBYTE(wVer);
  615. if (wVer >= 0x035F)
  616. return WIN95ORGREATHER;
  617. else
  618. return WIN32S;
  619. }
  620. #endif