Software Testing Learning Hub

Registry Editor in QTP

registry_editorQTP allows to create and edit a key values of registry.Registry handling is possible by using a wscript. shell object.

Refer a following code to add/edit registry values

Dim wshshell,companyname,emp1name

set wshshell=Createobject(“Wscript.shell”)

wshshell.RegWrite “HKEY_CURRENT_USER\Software\Company”,”Lion”,”Reg_SZ”

/* This will create a key in registry with the name company and add Lion as key with Reg_SZ key type *\

wshshell.RegWrite “HKEY_CURRENT_USER\Software\Company\Emp1″,”JOHN”,”Reg_SZ”

companyname=wshshell.RegRead(“HKCU\software\company\”)

emp1name=wshshell.RegRead(“HKCU\software\company\emp1”)

wshshell.RegDelete “HKCU\software\company\emp1”

wshshell.RegDelete “HKCU\software\company\”

Root key names in Registry-

Hkey_current_userHKCU
HKey_LOCAL_MACHINEHKLM
HKEY_CLASSES_ROOTHKCR
HKEY_USERSHKEY_USERS
HKEY_Current_CONFIGHKEY_Current_CONFIG

 Datatypes in Registry

Name of variablesDatatypes
REG_SZString
REG_DWordNumber
REG_BINARYBinary value
REG_EXPAND_SZDynamic string