home *** CD-ROM | disk | FTP | other *** search
/ DMI Interactive Gallery / GALLERY.BIN / setup / msregdb.inc < prev    next >
Text File  |  1993-04-12  |  5KB  |  140 lines

  1.  
  2. rem ---------------------------------------------------------------------
  3. rem
  4. rem MSREGDB.INC  - MSSETUP Include
  5. rem
  6. rem                Version 1.0
  7. rem
  8. rem                (c) 1988-1992 Apple Computer, Inc. All Rights Reserved.
  9. rem
  10. rem ---------------------------------------------------------------------
  11.  
  12.  
  13. '***************************************************************************
  14. '****************     registration database api's    ***********************
  15. '***************************************************************************
  16.  
  17. '$DEFINE REG_DB_ENABLED
  18.  
  19. const REG_SZ               = 1
  20. const HKEY_CLASSES_ROOT    = 1
  21. const ERROR_SUCCESS        = 0
  22.  
  23.  
  24. DECLARE FUNCTION EercErrorHandler LIB "mscomstf.dll" (grc%, fVital%, sz1$, sz2$, sz3$) AS INTEGER
  25. CONST GRC_API_FAILED       = 104
  26.  
  27. DECLARE FUNCTION RegOpenKey LIB "SHELL.DLL" (hKey&, szSubKey$, phkResult AS POINTER TO LONG) AS LONG
  28. DECLARE FUNCTION RegCreateKey LIB "shell.dll" (hKey&, szSubKey$, phkResult AS POINTER TO LONG) AS LONG
  29. DECLARE FUNCTION RegDeleteKey LIB "shell.dll" (hKey&, szSubKey$) AS LONG
  30. DECLARE FUNCTION RegCloseKey LIB "shell.dll" (hKey&) AS LONG
  31. DECLARE FUNCTION RegQueryValue LIB "shell.dll" (hKey&, szSubKey$, szValue$, lpcb AS POINTER TO LONG) AS LONG
  32. DECLARE FUNCTION RegSetValue LIB "shell.dll" (hKey&, szSubKey$, dwType&, szValue$, cbValue&) AS LONG
  33. DECLARE FUNCTION RegEnumKey LIB "shell.dll" (HkEY&, dwIndex&, szBuffer$, dwBufferSize&) AS LONG
  34.  
  35.  
  36. DECLARE SUB CreateRegKey(szKey$)
  37. DECLARE SUB CreateRegKeyValue(szKey$, szValue$)
  38. DECLARE SUB SetRegKeyValue(szKey$, szValue$)
  39. DECLARE SUB DeleteRegKey(szKey$)
  40. DECLARE FUNCTION GetRegKeyValue(szKey$) AS STRING
  41. DECLARE FUNCTION DoesRegKeyExist(szKey$) AS INTEGER
  42.  
  43.  
  44. 'NOTE: All keys are assumed to be subkeys of HKEY_CLASSES_ROOT. Therefore,
  45. 'the key HKEY_CLASSES_ROOT\key1\key2 would simply be written as key1\key2
  46. 'for these api's.
  47.  
  48.  
  49. '**************************************************************************
  50. SUB CreateRegKey(szKey$) STATIC
  51.     DIM phKey AS LONG
  52.  
  53.     IF RegCreateKey(HKEY_CLASSES_ROOT, szKey$, VARPTR(phKey)) > ERROR_SUCCESS THEN
  54.         i% = EercErrorHandler(GRC_API_FAILED, 1, "CreateRegKey", NULL, NULL)
  55. '$ifdef DEBUG
  56.         StfApiErr saeFail, "CreateRegKey", szKey$
  57. '$endif ''DEBUG
  58.         ERROR STFERR
  59.     END IF
  60.  
  61.     IF RegCloseKey(phKey) > ERROR_SUCCESS THEN
  62.         i% = EercErrorHandler(GRC_API_FAILED, 1, "CreateRegKey", NULL, NULL)
  63. '$ifdef DEBUG
  64.         StfApiErr saeFail, "CreateRegKey", szKey$
  65. '$endif ''DEBUG
  66.         ERROR STFERR
  67.     END IF
  68. END SUB
  69.  
  70.  
  71. '**************************************************************************
  72. SUB CreateRegKeyValue(szKey$, szValue$) STATIC
  73.     DIM phKey AS LONG
  74.  
  75.     IF RegSetValue(HKEY_CLASSES_ROOT, szKey$, REG_SZ,  szValue$, len(szKey$)) > ERROR_SUCCESS THEN
  76.         i% = EercErrorHandler(GRC_API_FAILED, 1, "CreateRegKeyValue", NULL, NULL)
  77. '$ifdef DEBUG
  78.         StfApiErr saeFail, "CreateRegKeyValue", szKey$+", "+szValue$
  79. '$endif ''DEBUG
  80.         ERROR STFERR
  81.     END IF
  82. END SUB
  83.  
  84.  
  85. '**************************************************************************
  86. FUNCTION DoesRegKeyExist(szKey$) STATIC AS INTEGER
  87.     DIM phKey AS LONG
  88.  
  89.     IF RegOpenKey(HKEY_CLASSES_ROOT, szKey$, VARPTR(phKey)) = ERROR_SUCCESS THEN
  90.         i = RegCloseKey(phKey)
  91.         DoesRegKeyExist = 1
  92.     ELSE
  93.         DoesRegKeyExist = 0
  94.     ENDIF
  95. END FUNCTION
  96.  
  97.  
  98. '**************************************************************************
  99. SUB SetRegKeyValue(szKey$, szValue$) STATIC
  100.     DIM phKey AS LONG
  101.  
  102.     IF RegSetValue(HKEY_CLASSES_ROOT, szKey$, REG_SZ,  szValue$, len(szKey$)) > ERROR_SUCCESS THEN
  103.         i% = EercErrorHandler(GRC_API_FAILED, 1, "SetRegKeyValue", NULL, NULL)
  104. '$ifdef DEBUG
  105.         StfApiErr saeFail, "SetRegKeyValue", szKey$+", "+szValue$
  106. '$endif ''DEBUG
  107.         ERROR STFERR
  108.     END IF
  109. END SUB
  110.  
  111.  
  112. '**************************************************************************
  113. FUNCTION GetRegKeyValue(szKey$) STATIC AS STRING
  114.     szValue$ = string$(512,32)
  115.     cb& = len(szValue$)
  116.  
  117.     IF DoesRegKeyExist(szKey$) = 0 THEN
  118.         GetRegKeyValue = ""
  119.         EXIT FUNCTION
  120.     END IF
  121.  
  122.     IF RegQueryValue(HKEY_CLASSES_ROOT, szKey$, szValue$, VARPTR(cb)) = ERROR_SUCCESS THEN
  123.         GetRegKeyValue = MID$(szValue$, 1, cb)
  124.     ELSE
  125.         i% = EercErrorHandler(GRC_API_FAILED, 1, "SetRegKeyValue", NULL, NULL)
  126. '$ifdef DEBUG
  127.         StfApiErr saeFail, "GetRegKeyValue", szKey$
  128. '$endif ''DEBUG
  129.         ERROR STFERR
  130.     END IF
  131.   szValue$ = ""
  132. END FUNCTION
  133.  
  134.  
  135. '**************************************************************************
  136. SUB DeleteRegKey(szKey$) STATIC
  137.     i& = RegDeleteKey(HKEY_CLASSES_ROOT, szKey$)
  138. END SUB
  139.  
  140.