I need to read a registry information about Oracle installation, so I’ve tried to use below code but I just see that reg.KeyCount is 0.
Actually, there are 3 items under KEY_OraClient11g_home1 folder.
dim reg as new registryitem(“HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraClient11g_home1”)
//reg =reg.child(“KEY_OraClient11g_home1”)
Dim lines() As String
Dim found As Boolean
MsgBox " reg.KeyCount : " + str(reg.KeyCount)
…
Can anyone let me know how to read that registry correctly?
I need to read a registry information about Oracle installation, so I’ve tried to use below code but I just see that reg.KeyCount is 0.
Actually, there are 3 items under KEY_OraClient11g_home1 folder.
dim reg as new registryitem(“HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraClient11g_home1”)
//reg =reg.child(“KEY_OraClient11g_home1”)
Dim lines() As String
Dim found As Boolean
MsgBox " reg.KeyCount : " + str(reg.KeyCount)
…
Can anyone let me know how to read that registry correctly?
[/quote]
Are you sure there are keys within HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraClient11g_home1 ? First thing to do is to use Regedit to check the structure, and see what is there. Then you will clearly know what is or not in there and be able to modfy your code accordingly.
For some other folders, I’m able to read the registry key information through the code above, but for some folders, I can’t.
I think this is related to registry permission.
However, even though I ran my application with administrator and put the all privileges on the folder, I got the same issue.
I’m not sure there is special consideration in handling registry information in Xojo.
For some other folders, I’m able to read the registry key information through the code above, but for some folders, I can’t.
I think this is related to registry permission.
However, even though I ran my application with administrator and put the all privileges on the folder, I got the same issue.
I’m not sure there is special consideration in handling registry information in Xojo.[/quote]
Unless a key has the same name as the containing folder, you were trying to look for keys inside a key. You need to go up a level to the path on the left that contains your three keys.
Then all you probably need to do is to look for your keys inside :
In the left pane,
HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraClient11g_home1
For the KEY_OraClient11g_home1 folder, it has 3 keys in right pane like below.
ORACLE_GROUP_NAME
ORACLE_HOME
ORACLE_HOME_NAME
And, these ones have its own value.
Of course, I’ve tried to use below one but zero value of reg.KeyCount.
dim reg as new registryitem(“HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE”)
If Oracle is installed in your environment, can you try to access the registry information?
That is strange. I am accessing the keys within HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\kbdclass\Enum in my latest app under Windows 10 Pro 64 bit, as well as Windows 8.1 Pro 64 bit without any special difficulty.
I looked at my Win 10 registry structure in Regedit, and as far as I can tell, only Apple and Microsoft seem to place anything under Wov6432Node in HKEY_CLASSES_ROOT\VirtualStore\MACHINE\SOFTWARE\Wow6432Node. Oracle\VirtualBox is not under any Wow6432Node.
At any rate, thank you for the tip. Will remember it in case I encounter a strange behavior there.
[quote=177212:@changwon lee]dim reg as new registryitem(“HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ORACLE\KEY_OraDb11g_home1”)
I am able to get the all key values there.[/quote]
er, not exactly what I was getting at… I believe Xojo always uses that Wow6432node anyway, what is harder is looking at values stored outside (IE: values for 64.bit apps) …
Are you sure it is not that you had success looking for the value name “KEY_OraDb11g_home1” which I cannot see amongst the ones you mentioned earlier ? ( They had ...OraClient... not ...OraDb... )
There are several child folders under the initial RegistryItem, so I needed to parse it more like below.
A little bit messy but it works well for my requirement to get the ORACLE_HOME value.
#If Target64Bit Then
dim reg as new RegistryItem(“HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ORACLE”) #Endif
#If Target32bit Then
dim reg as new RegistryItem(“HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE”) #Endif
dim tryreg as RegistryItem
dim folders() as string
dim i as integer
dim path As String
Dim getORACLE_HOME As String
for i= 0 to reg.FolderCount-1
folders.append reg.item(i).path
If InStr(folders(i), "KEY_Ora") > 0 Then
path = folders(i)
tryreg = New RegistryItem(path)
for i= 0 to tryreg.KeyCount- 1
If tryreg.name(i) = "ORACLE_HOME" Then
getORACLE_HOME = tryreg.value(i)
Return getORACLE_HOME
End If
next
End If
[quote=177229:@Michel Bujardet]That is strange. I am accessing the keys within HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\kbdclass\Enum in my latest app under Windows 10 Pro 64 bit, as well as Windows 8.1 Pro 64 bit without any special difficulty.
I looked at my Win 10 registry structure in Regedit, and as far as I can tell, only Apple and Microsoft seem to place anything under Wov6432Node in HKEY_CLASSES_ROOT\VirtualStore\MACHINE\SOFTWARE\Wow6432Node. Oracle\VirtualBox is not under any Wow6432Node.[/quote]
I believe 32.bit apps use Wow6432Node by default in 64.bit windows O/Ss for HKEY_LOCAL_MACHINE and probably the USER ones
There is a flag in the API to override it, but that is not (yet) and option in XOJO.
Looks like HKEY_CLASSES_ROOT behaves differently !
If I try to access “HKEY_LOCAL_MACHINE\SOFTWARE\MyTest”
it does not find it there, but does find it in “HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\MyTest”
on a 64.bit system.
If I try to access a value under HKEY_CLASES_ROOT\MyTest
it finds it there OK (!)
#If TargetWin32 Then
Soft Declare Function GetCurrentProcess Lib "kernel32" As Integer
Dim processID As Integer
processID = GetCurrentProcess
Soft Declare Function IsWow64Process Lib "kernel32" (handle As Integer, ByRef result As Boolean) As Integer
If System.IsFunctionAvailable( "IsWow64Process", "Kernel32" ) Then
Dim value As Boolean
Call IsWow64Process(processID, value)
if value Then
return True
else
return False
end if
End If
#Endif
return False
[quote=177296:@Ashot Khachatryan]How to check if Windows is 64bit:
[code] #If TargetWin32 Then
Soft Declare Function GetCurrentProcess Lib “kernel32” As Integer
Dim processID As Integer
processID = GetCurrentProcess
Soft Declare Function IsWow64Process Lib "kernel32" (handle As Integer, ByRef result As Boolean) As Integer
If System.IsFunctionAvailable( "IsWow64Process", "Kernel32" ) Then
Dim value As Boolean
Call IsWow64Process(processID, value)
if value Then
return True
else
return False
end if
End If
If you are not sure if the registry item exists on a system, be sure to pass the optional CREATE flag to New RegistryItem. Otherwise it will try to create the item.
dim reg as RegistryItem
Try
reg = new RegistryItem("HKEY_LOCAL_MACHINE\\SOFTWARE\\ORACLE\", FALSE)
Catch e as RegistryAccessErrorException
// doesn't exist
End
In case there is no Oracle client(registry information), below code got RegistryAccessErrorException.
[code] dim reg as RegistryItem
Try
'RegistryItem.Constructor(path as String , create as Boolean)
reg = new RegistryItem(“HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE”, TRUE)
Catch e as RegistryAccessErrorException
MsgBox “Registry information doesn’t exist”
Return “NO”
End
[/code]
I just want to let user know the fact that there is no oracle.
Can you please let me know how to do it?