
Returns the type of data for the specified subkey.
RegEntryType(handle, subkey-string [,view-flag])
(i) handle an open registration database key. (see below).
(s) subkey-string a path from the key provided to the desired key.
(i) view-flag [optional] controls which registry view the function uses when accessing the Windows registry.
0 - view indicated by the last call to the RegOpenFlags.
32 - use the 32-bit registry view.
64 - use the 64-bit registry view.
(s) data type of specified subkey. (see below).
The return value will be one of the following:
|
Value |
Type |
Meaning |
|
0 |
(REG_NONE) |
No value type |
|
1 |
(REG_SZ) |
An ANSI string |
|
2 |
(REG_EXPAND_SZ) |
An ANSI string that contains unexpanded references to environment variables (for example, "%PATH%"). |
|
3 |
(REG_BINARY) |
Free form binary |
|
4 |
(REG_DWORD) |
32-bit number |
|
5 |
(REG_DWORD_BIG_ENDIAN) |
32-bit number High byte first |
|
6 |
(REG_LINK) |
Symbolic Link (Unicode) |
|
7 |
(REG_MULTI_SZ) |
A delimited list of ANSI strings. |
|
8 |
(REG_RESOURCE_LIST) |
Resource list in the resource map |
|
9 |
(REG_FULL_RESOURCE_DESCRIPTOR) |
Resource list in the hardware description |
|
10 |
(REG_RESOURCE_REQUIREMENTS_LIST) |
Resource requirements |
|
11 |
(REG_QWORD) |
64-bit number |
View-flag
This optional parameter controls which registry view the function uses when accessing the Windows registry. The optional parameter's values can be 32 to use the 32-bit view, 64 to use the 64-bit view, or 0 to use the view indicated by the last call to the RegOpenFlags. The parameter value of 0 can also causes a function to use the WinBatch default 64-bit view, if no call to RegOpenFlags has been made and setting the parameter to 0 is equivalent to omitting the parameter entirely.
Notes:
Using the 32 or 64 values cause these functions to error if a function's subkey parameter contains the string 'wow6432node'.
Setting the parameter to one of the valid values has no effect when running on 32-bit Windows.
;This set of UDFs can clone or rename a registry key
;It is not blindingly fast, but should be ok for smaller trees.
;
;CopyRegValue - Copies one single value from one place to another
;
;CloneRegTree - copies one tree from one place to another
;
;RenameRegTree - Renames a tree.
;
;However, due to the fact that the registry API does not have
;a rename facility, the RenameRegTreeis implemented by first
;cloning the tree, then deleting the original tree.
;
;Keys are used by first obtaining a handle to one. One of the
;predefined handles (@REGMACHINE @REGCURRENT, etc) or a handle
;returned by one of the registry functions RegConnect, RegCreateKey
;or RegOpenKey may be used
;Each function needs a handle to a section in the registry
;database in addition to a string that consists of the subkey to
;an entry in the Registry database.
;
;For current versions of Windows, there are 4 handles: @REGMACHINE,
;@REGCLASSES, @REGUSRS, and @REGCURRENT. These are WIL constants
;for HKEY_LOCAL_MACHINE, HKEY_CLASSES_ROOT, HKEY_USERS, and
;HKEY_CURRENT_USER. When you obtain a registry subkey from Microsoft's
;registry viewer, regedit.exe (by using Copy Key Name from the right
;mouse menu in RegEdit.exe) it will look like this example:
;HKEY_LOCAL_MACHINE\SOFTWARE\myTest\Sub2\sub21\Sub211
;
;For use in the WIL registry functions, the above key must be
;divided into handle and subkey. The handle, @REGMACHINE, takes the
;place of the first item, 'HKEY_LOCAL_MACHINE\'. The subkey needed
;for the second parameter in the functions is,
;'SOFTWARE\myTest\Sub2\sub21\Sub211'.
;Note: it does not start with the '\' backslash character.
;
;
;Define the CopyRegValue UDF.
#DefineFunction CopyRegValue(fromHandle,fromSubkey,toHandle,toSubkey)
;Stop if value does not exist.
Terminate(RegExistValue(fromHandle,fromSubkey)==0,"Reg value does not exist",fromSubkey)
;Get the entry type
type=RegEntryType(fromHandle,fromSubkey)
;Stop if type is not supported.
Terminate( ((type<1) || (type>4)) && type!=7, "Cannot handle reg value",fromSubkey)
;Define a hopefully sufficiently obscure delimiter for the BIN function
delim=Num2Char(255)
;Get the value.
value=RegQueryEx(fromHandle,fromSubkey,delim,type)
;Copy value to a new subkey.
RegSetEx(toHandle,toSubkey,value,delim,type)
Return ;Return nothing.
#EndFunction
;Define the CloneRegTree UDF.
#DefineFunction CloneRegTree(fromHandle, fromSubkey, toHandle, toSubkey)
;Stop if key does not exist.
Terminate(RegExistKey(fromHandle,fromSubkey)==0,"Reg key does not exist",fromSubkey)
;copy top default key
;Check value.
If RegExistValue(fromhandle,fromsubkey)
;Get value.
defval=RegQueryValue(fromHandle,fromSubkey)
;Set value of destination subkey.
If defval!="" Then RegSetValue(toHandle,toSubkey,defval)
EndIf
;copy all values under key, if any
items=RegQueryItem(fromHandle,fromSubkey)
icount=ItemCount(items,@TAB)
For ii=1 To icount
;Assemble source subkey with value in brackets.
thisitem=StrCat(fromSubkey,'[',ItemExtract(ii,items,@TAB),']')
;Assemble destination subkey with value in brackets.
thatitem=StrCat(toSubkey,'[',ItemExtract(ii,items,@TAB),']')
;Copy the entry.
CopyRegValue(fromHandle, thisitem, toHandle, thatitem)
Next
;Get list of subkeys
;Open source key with read access rights.
tempkey=RegOpenKeyEx(fromHandle,fromSubkey,"READ",0,0)
;Get keys.
keys=RegQueryKeys(tempkey)
;Close source key.
RegCloseKey(tempkey)
;Process each subkey
kcount=ItemCount(keys,@TAB)
For kk=1 To kcount
thiskey=StrCat(fromSubkey,"\",ItemExtract(kk,keys,@TAB))
thatkey=StrCat(toSubkey,"\",ItemExtract(kk,keys,@TAB))
;Use the CloneRegTree UDF to do the work.
CloneRegTree(fromHandle,thiskey,toHandle,thatkey)
Next
#EndFunction
#DefineFunction RenameRegTree(fromHandle, fromSubkey, toHandle, toSubkey)
;Set up UDF
;Use previous UDF to copy the source key to the destination key.
CloneRegTree(fromHandle, fromSubkey, toHandle, toSubkey)
;Delete the source key.
RegDeleteKey(fromHandle,fromSubkey)
#EndFunction
;Test code follows.
;Registry handle. In this case, both source and destination are the same.
fromHandle = @REGCURRENT
toHandle = @REGCURRENT
;source subkey
fromSubkey = "Software\Wilson WindowWare"
;destination subkey
toSubkey = "Software\MyWilson WindowWare"
;copy the subkey
CloneRegTree( fromHandle , fromSubkey , toHandle , toSubkey)
Message("Progress" , "New key created.%@CRLF%%@CRLF%See this with regedit.exe, %@CRLF%Be sure to refresh it with f5!")
fromSubkey = "Software\MyWilson WindowWare"
toSubkey = "Software\MyOtherWilson WindowWare"
;copy the subkey to a new named key, and delete the old key.
RenameRegTree( fromHandle , fromSubkey , toHandle , toSubkey)
Message("Progress" , "New key copied and renamed.%@CRLF%Check this with f5 in regedit.exe.")
RegQueryEx, RegSetEx and the section on Registration Database Operations