
Possible to use Reflection on Registry Class?
Hi,
Is it possible to use reflection to get a RegistryKey from the Registry
class?
I tried the code below but since I can't declare the registry class As New
it wont work!
Perhaps I'm doing something wrong but don't know what.
x = GetRegKey("CurrentUser") 'For example
'Function to return the chosen registry key by its name.
Friend Function GetRegKey(ByVal strName As String) As RegistryKey
Dim typRegType As Type
Dim objRegistry As Registry
Dim objFieldInfo As FieldInfo
typRegType = objRegistry.GetType
objFieldInfo = typRegType.GetField(strName)
GetRegKey = objFieldInfo.GetValue(objFieldInfo)
End Function
--
Thanks in advance
Ali Eghtebas Sweden