CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2001
    Location
    Chile
    Posts
    6

    VB 6.0 and Registry System.

    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.



  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: VB 6.0 and Registry System.

    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
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Jun 2001
    Location
    Chile
    Posts
    6

    Re: VB 6.0 and Registry System.

    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.


  4. #4
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: VB 6.0 and Registry System.

    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
    [email protected]
    Iouri Boutchkine
    [email protected]

  5. #5
    Join Date
    Jun 2001
    Location
    Chile
    Posts
    6

    Re: VB 6.0 and Registry System.

    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.



  6. #6
    Join Date
    Jun 2001
    Location
    Chile
    Posts
    6

    Re: VB 6.0 and Registry System.

    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.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured