|
-
Aug 26th, 2004, 01:05 AM
#1
Thread Starter
Hyperactive Member
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
-
Aug 26th, 2004, 01:52 AM
#2
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
-
Aug 26th, 2004, 02:25 AM
#3
Thread Starter
Hyperactive Member
It is true, the code is not mine. I`ll take a look at the codebase in search for alternative coding.
George Papadopoulos
-
Aug 26th, 2004, 02:33 AM
#4
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:
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
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.
Private Const REG_SZ = 1 ' Unicode nul terminated string
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
-
Aug 27th, 2004, 03:06 AM
#5
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|