Results 1 to 5 of 5

Thread: VB6 and SZ registry entry

  1. #1

    Thread Starter
    Hyperactive Member divined's Avatar
    Join Date
    Aug 2004
    Location
    Thessaloniki, Greece
    Posts
    447

    VB6 and SZ registry entry

    Hello everybody

    I think I have a rather trivial problem. Unfortunately, I have not been able to come up with a solution. I am trying to create a couple of string (zero terminated) key entries. The string to be entered in the registry comes from a text box on a form (txtServerIP).
    When I write the value of the text box to the registry, the value is written as a double word whereas I would like to have it stored as string.
    The text box is supposed to store an IP address as a string. Could the periods of an IP address cause a problem?

    The code is as shown below :

    Private Sub OKButton_Click()

    Dim strServerIP As String

    strServerIP = txtServerIP.Text

    ' Check whether key 'SOFTWARE\LEAP_SOFTWARE exists. If not then create key
    ' 'SOFTWARE\LEAP_SOFTWARE\EPEMBATHS' and set key values. Otherwise just
    ' set key values.

    If RegistryModule.regDoes_Key_Exist(HKEY_LOCAL_MACHINE, "SOFTWARE\LEAP_SOFTWARE") Then
    RegistryModule.regCreate_Key_Value HKEY_LOCAL_MACHINE, "SOFTWARE\LEAP_SOFTWARE\EPEMBATHS", "MY_SQL_SERVER_IP", strServerIP
    RegistryModule.regCreate_Key_Value HKEY_LOCAL_MACHINE, "SOFTWARE\LEAP_SOFTWARE\EPEMBATHS", "DATABASE_NAME", "biotech"
    Else
    RegistryModule.regCreate_A_Key HKEY_LOCAL_MACHINE, "SOFTWARE\LEAP_SOFTWARE\EPEMBATHS"
    RegistryModule.regCreate_Key_Value HKEY_LOCAL_MACHINE, "SOFTWARE\LEAP_SOFTWARE\EPEMBATHS", "MY_SQL_SERVER_IP", strServerIP
    RegistryModule.regCreate_Key_Value HKEY_LOCAL_MACHINE, "SOFTWARE\LEAP_SOFTWARE\EPEMBATHS", "DATABASE_NAME", "biotech"
    'RegistryModule.regCreate_A_Key HKEY_LOCAL_MACHINE, "SOFTWARE\LEAP_SOFTWARE\EPEMBATHS\MY_SQL_SERVER_IP"
    'RegistryModule.regCreate_A_Key HKEY_LOCAL_MACHINE, "SOFTWARE\LEAP_SOFTWARE\EPEMBATHS\DATABASE_NAME"
    End If

    Any suggestions?

    thx, in advance

    George Papadopoulos

  2. #2
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    It looks as if you are using someone elses Registry code to do what you want. Search these forums (particularly the CodeBank) for other peoples Registry Modules. I've seen a couple (not sure if it was here) which allow you to choose the type you want to store.

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  3. #3

    Thread Starter
    Hyperactive Member divined's Avatar
    Join Date
    Aug 2004
    Location
    Thessaloniki, Greece
    Posts
    447
    It is true, the code is not mine. I`ll take a look at the codebase in search for alternative coding.

    George Papadopoulos

  4. #4
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    pfft, this is how newbish I have become. It appears that there are these strange things now....A P I?

    Anyway, try looking into these:
    VB Code:
    1. Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    2. Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long         ' Note that if you declare the lpData parameter as String, you must pass it By Value.
    3.  
    4. Private Const REG_SZ = 1                         ' Unicode nul terminated string
    5. Private Const REG_DWORD = 4                      ' 32-bit number
    The dwType parameter lets you set it as REG_SZ (and DWORD if thats what your after...which you aren't).

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  5. #5

    Thread Starter
    Hyperactive Member divined's Avatar
    Join Date
    Aug 2004
    Location
    Thessaloniki, Greece
    Posts
    447
    ok. thx, phReak.

    Everyone has been a newbie at one point of his life! The significant thing is that you try to progress!

    George Papadopoulos

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