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

  1. /* MakeSKey - March 26th, 2001
  2. **
  3. **      Copyright (c) 1997-2001 by Gregory Braun. All rights reserved.
  4. **
  5. **      This function creates a System Registry RunServices entry.
  6. **
  7. **      Called:     srv = a pointer to the SRV 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. **                              CurrentVersion
  18. **                                RunSerivces
  19. **                                  Title = d:\folder\program.exe /flags
  20. **
  21. */
  22.  
  23.  
  24. #include "AppPaths.h"
  25.  
  26. extern BOOL far MakeSKey (LPSRV srv)
  27. {
  28.     auto HKEY   key = NULL;
  29.     auto LONG   err = NIL;
  30.  
  31.     auto DWORD  size;
  32.     auto DWORD  result;
  33.  
  34.     auto char sub[PSTRING];
  35.  
  36.     lstrcpy (sub,REGSTR_PATH_RUNSERVICES);
  37.  
  38.     err = RegCreateKeyEx (HKEY_LOCAL_MACHINE,
  39.                           sub,
  40.                           NIL,
  41.                           BLANK_STR,
  42.                           REG_OPTION_NON_VOLATILE,
  43.                           KEY_SET_VALUE,
  44.                           NULL,
  45.                           &key,
  46.                           &result);
  47.  
  48.     if (err != ERROR_SUCCESS)
  49.         return (FALSE);
  50.  
  51.     if (*srv->path) {
  52.  
  53.         size = lstrlen (srv->path) + 1;
  54.  
  55.         err = RegSetValueEx (key,
  56.                              srv->name,
  57.                              NIL,
  58.                              REG_SZ,
  59.                              (CONST BYTE *) srv->path,
  60.                              size);
  61.         }
  62.  
  63.     RegCloseKey (key);
  64.  
  65.     return ((err == ERROR_SUCCESS) ? TRUE : FALSE);
  66. }
  67.  
  68. /* end of MakeSKey.c - written by Gregory Braun */
  69.