home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 22 / PCPP #22.iso / Quake2 / q2source_12_11 / utils3 / qe4 / mru.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-23  |  18.6 KB  |  650 lines

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