Click to See Complete Forum and Search --> : VB 6.0 and Registry System.
Rodolfo Aranda
June 29th, 2001, 09:35 AM
Hi, we are working with VB 6.0 and WIN 98, we need to catch a value from a key of the pc registry system. This value is a name of a driver informix that in different pcs it can be different ... This is necesary in order to prepare a string of connection without data sources names in ODBC ...
Can anybody help us ???
Thaks in advance, and regards from Chile.
Iouri
June 29th, 2001, 09:50 AM
here the code how to read registry
'PLACE ALL THIS INTO A NEW MODULE or IN Declarations OF YOUR FORM
Public Sub CreateKey(Folder As String, Value As String)
Dim b As Object
On Error Resume Next
Set b = CreateObject("wscript.shell")
b.RegWrite Folder, Value
End Sub
Public Sub CreateIntegerKey(Folder As String, Value As Integer)
Dim b As Object
On Error Resume Next
Set b = CreateObject("wscript.shell")
b.RegWrite Folder, Value, "REG_DWORD"
End Sub
Public Function ReadKey(Value As String) As String
'READ FROM WINDOWS REGISTRY
'.........................
Dim b As Object
On Error Resume Next
Set b = CreateObject("wscript.shell")
r = b.RegRead(Value)
ReadKey = r
End Function
Public Sub DeleteKey(Value As String)
'DELETE VALUES FROM WINDOWS REGISTRY
'-----------------------------------
Dim b As Object
On Error Resume Next
Set b = CreateObject("Wscript.Shell")
b.RegDelete Value
End Sub
'form==============
'To Create an registry key:
CreateKey "HKEY_CURRENT_USER\Software\My Software\Version","1.45"
'To Create an Integer registry key:
CreateIntegerKey "HKEY_CURRENT_USER\Software\My Software\Number","50"
'To Read from the registry
msgbox "Version is " & ReadKey("HKEY_CURRENT_USER\Software\My Software\Version"
'To Delete from the registry
DeleteKey "HKEY_CURRENT_USER\Software\My Software\Version"
' Instead of writing out HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER etc, you can
' use abbreviations such as "HKCU\Software"
Iouri Boutchkine
iouri@hotsheet.com
Rodolfo Aranda
June 29th, 2001, 11:30 AM
Thank you very much. It really works !!!
And one more thing ... How do you catch a list of items or entries for a registry system Path ??? Is there any manner ... ?
Thanks again.
Iouri
June 29th, 2001, 11:50 AM
First of all, rate it if it helped you.
2.I really did not understand what you mean by catching the list of items for a registry system path.
Iouri Boutchkine
iouri@hotsheet.com
Rodolfo Aranda
June 29th, 2001, 02:29 PM
Thanks for your answer.
We already have done to work your previous module and it runs without problems. We are going to use it. Now we need to get the keys below other key. Specifically:
"HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST.INI".
Do you understand me?
Thanks.
Rodolfo Aranda
July 4th, 2001, 03:19 PM
Finally, we used a module included in an example of Visual Basic. This module is called mdlRegistro. The functions used were:
n = EnumKey(HKEY_LOCAL_MACHINE, "Software\ODBC\ODBCINST.INI", vSubkey)
vSubkey is a variant and contains a list of n subkeys, and
sVersion(j) = QueryValue(HKEY_LOCAL_MACHINE, "Software\ODBC\ODBCINST.INI\" & vSubkey(j), "DriverODBCVer")
Thanks.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.