Working with Windows Registry
REG-SZ: "registry_path" "string_value"
Adds a string value to a key specified in registry path. (If the key does not exist, it will be created).
#( test_reg_sz NoActive Action: REG-SZ: "HKEY_LOCAL_MACHINE\SOFTWARE\test\first" "test string value" )#
REG-DWORD: "registry_path" <number>
Adds a numerical value to the key specified in registry path. (If this key does not exist, it will be created).
DWORD (double word) is a 32-bit value, 8 hexadecimal digits.
#( test_reg_dword NoActive Action: REG-DWORD: "HKEY_LOCAL_MACHINE\SOFTWARE\test\second" 16 )#
There also exists a postfix version of this word (it is convenient to use it when working with variables):
S" HKEY_LOCAL_MACHINE\SOFTWARE\test\first" 16 REG-DWORD S" HKEY_LOCAL_MACHINE\SOFTWARE\test\first" first_var @ REG-DWORD
Deletes a specified key and all of its subkeys from the registry.
#( test_reg_delete_key NoActive Action: REG-DELETE-KEY: "HKEY_LOCAL_MACHINE\SOFTWARE\test" )#
Deletes a specified value from Windows registry. Can be used with both string and numerical values.
#( test_reg_delete_value NoActive Action: REG-DELETE-VALUE: "HKEY_LOCAL_MACHINE\SOFTWARE\test\first" REG-DELETE-VALUE: "HKEY_LOCAL_MACHINE\SOFTWARE\test\second" )#
REG-KEY-EXIST? ( a u -- ?)
Postfix word which checks the existance of the specifyed registry key. Returns TRUE (-1) if the key exists and FALSE (0) otherwise.
#( test_reg_key_exist NoActive Action: S" HKEY_LOCAL_MACHINE\SOFTWARE" REG-KEY-EXIST? IF \ do smth useful THEN )#
<buffer> GET-REG: "registry_path"
Gets and records a specified value from the registry into a buffer created by the user.
String values should be placed in arrays, and numerical values in variables.
#( test_get_reg NoActive CREATE reg_value 256 ALLOT Action: reg_value GET-REG: "HKEY_LOCAL_MACHINE\SOFTWARE\test\first" MSG: "We have extracted a string value: %reg_value ASCIIZ>%" )# #( test_get_reg1 NoActive VARIABLE reg_variable Action: reg_variable GET-REG: "HKEY_LOCAL_MACHINE\SOFTWARE\test\second" MSG: "We have extracted a numerical value: %reg_variable @%" )#
Word ASCIIZ> separates address of zero-terminated string into an address and a character count.
1) We would like to point out that editing Windows registry (especially removing keys whose purpose you don't know), is a rather dangerous activity, therefore we suggest that you create a backup copy of the registry.
2) One shouldn't use nnCron to access any entries in HKEY_CURRENT_USER subtree. nnCron is run by "user" SYSTEM and cannot access this branch, because from the viewpoint of user SYSTEM, branches of other users are located in subtree HKEY_USERS. In Win2000/XP, you can use the word NAME2SIDS to access user's branches in subtree HKEY_USERS.