Kbase 21529: How to create and read Windows registry keys
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  16/10/2008 |
|
Status: Verified
GOAL:
How to create Windows registry keys
GOAL:
How to read Windows registry keys
GOAL:
How to set Windows registry keys
GOAL:
How to get Windows registry keys
GOAL:
How to read registry keys using LOAD
GOAL:
How to read registry keys using UNLOAD
GOAL:
How to read registry keys using GET-KEY-VALUE
GOAL:
How to create registry keys using PUT-KEY-VALUE
GOAL:
Example of create and read registry keys
FACT(s) (Environment):
Windows NT 32 Intel/Windows 2000
FIX:
Setting registry entries during program execution is a method used by application programmers to retain application information.
Here is an example of how to create and read registry keys using the LOAD, UNLOAD, GET-KEY-VALUE, and PUT-KEY-VALUE statements.
IMPORTANT NOTE: Progress recommends that the registry be backed up before any changes are made to it. A modification to the registry might make the OS unusable.
/* Example of creating and reading registry keys */
/* Using LOAD and UNLOAD */
/* This example creates a key named */
/* Clue\TEMP-PRGM\DATA under HKEY_LOCAL_MACHINE\PSC\ */
/* and places some value into it. Then, it reads */
/* the value and displays it. */
FUNCTION getData RETURNS CHARACTER ().
DEF VAR DATA AS CHARACTER NO-UNDO.
LOAD "SOFTWARE" BASE-KEY "HKEY_LOCAL_MACHINE".
USE "SOFTWARE".
GET-KEY-VALUE SECTION "PSC\Clue\TEMP-PRGM"
KEY "DATA"
VALUE DATA.
UNLOAD "SOFTWARE".
RETURN (DATA).
END FUNCTION.
FUNCTION makeClue RETURN CHARACTER ().
LOAD "SOFTWARE" BASE-KEY "HKEY_LOCAL_MACHINE".
USE "SOFTWARE".
PUT-KEY-VALUE SECTION "PSC\Clue\TEMP-PRGM"
KEY "DATA"
VALUE "Here, this is the value in the registry".
UNLOAD "SOFTWARE".
RETURN ("Made Clue").
END FUNCTION.
MESSAGE makeClue() VIEW-AS ALERT-BOX.
MESSAGE getData() VIEW-AS ALERT-BOX.