Pages

Wednesday, 19 October 2011

QTP Script: Read a value from a key in the registry


' =============================================================
' function : RegistryRead
' desc     : Read a value from the registry
' params   : strRoot is the root key, i.e. "HKLM", "HKCU"
'            strPath is the path to read, i.e. 
'            "Software\Test\Automation"
' returns :  Value from the registry key
' =============================================================
Function RegistryRead(strRootstrPath)

' create the shell object
Set objShell = CreateObject("WScript.Shell")

' read the key
strValue = objShell.RegRead(strRoot & "\" & strPath)

' return the value
RegistryRead = strValue

' destroy the object
Set objShell = Nothing

End Function 'RegistryRead

0 comments:

Post a Comment