home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / Chip_2002-02_cd1.bin / sharewar / apaths / APSOURCE.ZIP / GetHKeys.c < prev    next >
C/C++ Source or Header  |  2001-03-26  |  2KB  |  82 lines

  1. /* GetHKeys - March 26th, 2001
  2. **
  3. **      Copyright (c) 1997-2001 by Gregory Braun. All rights reserved.
  4. **
  5. **      This function searches the MS Windows 95/NT System Registry,
  6. **      enumerating all Help key values it finds.
  7. **
  8. **      Called:     list = Handle to the ListView control to be filled.
  9. **
  10. **      Returns:    TRUE upon success, or FALSE if an error exists.
  11. **
  12. **      Notes:      This routine searchs the following key:
  13. **
  14. **                      HKEY_LOCAL_MACHINE
  15. **                        Software
  16. **                          Microsoft
  17. **                            Windows
  18. **                              Help
  19. **                                HELPFILE.HLP = d:\folder
  20. **
  21. */
  22.  
  23. #include "AppPaths.h"
  24.  
  25. extern BOOL far GetHKeys (HWND list)
  26. {
  27.     auto HKEY       key     = NULL;
  28.     auto DWORD      inx     = NIL;
  29.     auto LV_ITEM    item    = { NIL };
  30.  
  31.     auto LONG       err;
  32.     auto DWORD      size;
  33.     auto DWORD      len;
  34.  
  35.     auto char       sub[PSTRING];
  36.     auto char       value[PSTRING];
  37.  
  38.     auto char       help[PSTRING];
  39.  
  40.     lstrcpy (sub,REGSTR_PATH_HELP);
  41.  
  42.     err = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
  43.                         sub,
  44.                         NIL,
  45.                         KEY_READ,
  46.                         &key);
  47.  
  48.     if (err != ERROR_SUCCESS)
  49.         return (FALSE);
  50.  
  51.     ListView_DeleteAllItems (list);
  52.  
  53.     do {
  54.  
  55.         size = PSTRING;
  56.         len  = PSTRING;
  57.  
  58.         if ((err = RegEnumValue (key,inx,value,&size,NULL,NULL,(LPBYTE) help,&len)) != ERROR_SUCCESS) {
  59.             inx++;
  60.             continue;
  61.             }
  62.  
  63.         item.mask = LVIF_TEXT;
  64.  
  65.         item.iItem = inx;
  66.         item.iSubItem = COLUMN_1;
  67.         item.pszText = value;
  68.         
  69.         ListView_InsertItem (list,&item);
  70.         ListView_SetItemText (list,inx,COLUMN_2,help);
  71.  
  72.         inx++;
  73.  
  74.         } while (err != ERROR_NO_MORE_ITEMS);
  75.  
  76.     if (key) RegCloseKey (key);
  77.  
  78.     return ((inx) ? TRUE : FALSE);
  79. }
  80.  
  81. /* end of GetHKeys.c - written by Gregory Braun */
  82.