Reading Registry in a 16-bit program 
Author Message
 Reading Registry in a 16-bit program

I am trying to retrieve a value from the registry in VB4-16 using
RegQueryValue and the following code.  I always get a return value of 2
from the RegQueryValue call.  I know the key exists and has a value in it.
I am not sure about my declarations or how I have dimmed the variable Ans
or AnsSize.  I am having a lot of trouble finding help on the use of the
16-bit functions.

Private Declare Function RegQueryValue Lib "shell.dll" (ByVal hKey As Long,
ByRef lpSubKey As String, ByRef lpValue As String, ByRef lpcbValue As Long)
As Long
Private Declare Function RegOpenKey Lib "shell.dll" (ByVal hKey As Long,
ByVal lpSubKey As String, ByRef phkResult As Long) As Long
Private Declare Function RegCloseKey Lib "shell.dll" (ByVal hKey As Long)
As Long

Dim hKey As Long
Dim RetVal As Long
Dim Ans As String * 255
Dim AnsSize As Long
Dim SubKey As String

Const HKEY_CURRENT_USER = &H80000001

SubKey = "Software\Microsoft\Windows Messaging Subsystem\Profiles"
AnsSize = Len(Ans)

RetVal = RegOpenKey(HKEY_CURRENT_USER, SubKey, hKey)
If RetVal <> 0 Then
   MsgBox "can't find key"
   End
End If
SubKey = "DefaultProfile"
RetVal = RegQueryValue(hKey, SubKey, Ans, AnsSize)
If RetVal <> 0 Then
   MsgBox "can't find value"
   End
End If
Label1.Caption = Ans
Label1.Refresh
RetVal = RegCloseKey(hKey)

Thanks in advance

Jeff DeRouse



Mon, 28 Feb 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Reading WIndows95 System Registry using 16 bit VB

2. 16-bit VB programs into 32-bit programs

3. how to speed up 16 bit program in 32 bit GDI

4. 16-bit Program Termination under 32-bit Systems

5. 32 Bit Program to call 16 Bit DLL

6. Is there any way to detect if Win32/16 with a 16-bit program

7. Converting 32bit VB programs to 16 bit VB programs

8. Calling 16 bit DLL from VB4 16 bit in Win 95

9. VB 4.0 (16-Bit)/Crystal Reports 3.0.1.32 (16-Bit) Print Preview Maximize Window

10. vb400 16 bit installation in an novell 16 bit network

11. corruption of 16 bit db when used by both 16 and 32 bit apps

 

 
Powered by phpBB® Forum Software