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

  1. /* MakeHKey - March 26th, 2001
  2. **
  3. **      Copyright (c) 1997-2001 by Gregory Braun. All rights reserved.
  4. **
  5. **      This function creates a System Registry Help entry.
  6. **
  7. **      Called:     help = a pointer to the HELP data structure to use.
  8. **
  9. **      Returns:    TRUE upon success, or FALSE if an error exists.
  10. **
  11. **      Notes:      This routine creates the following key:
  12. **
  13. **                      HKEY_LOCAL_MACHINE
  14. **                        Software
  15. **                          Microsoft
  16. **                            Windows
  17. **                              Help
  18. **                                HELPFILE.HLP = d:\folder
  19. **
  20. */
  21.  
  22.  
  23. #include "AppPaths.h"
  24.  
  25. extern BOOL far MakeHKey (LPHELP help)
  26. {
  27.     auto HKEY   key = NULL;
  28.     auto LONG   err = NIL;
  29.  
  30.     auto DWORD  size;
  31.     auto DWORD  result;
  32.  
  33.     auto char sub[PSTRING];
  34.  
  35.     lstrcpy (sub,REGSTR_PATH_HELP);
  36.  
  37.     err = RegCreateKeyEx (HKEY_LOCAL_MACHINE,
  38.                           sub,
  39.                           NIL,
  40.                           BLANK_STR,
  41.                           REG_OPTION_NON_VOLATILE,
  42.                           KEY_SET_VALUE,
  43.                           NULL,
  44.                           &key,
  45.                           &result);
  46.  
  47.     if (err != ERROR_SUCCESS)
  48.         return (FALSE);
  49.  
  50.     if (*help->path) {
  51.  
  52.         size = lstrlen (help->path) + 1;
  53.  
  54.         err = RegSetValueEx (key,
  55.                              help->name,
  56.                              NIL,
  57.                              REG_SZ,
  58.                              (CONST BYTE *) help->path,
  59.                              size);
  60.         }
  61.  
  62.     RegCloseKey (key);
  63.  
  64.     return ((err == ERROR_SUCCESS) ? TRUE : FALSE);
  65. }
  66.  
  67. /* end of MakeHKey.c - written by Gregory Braun */
  68.