mru.c 19 KB

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