Late bind ActiveX DLL problem

C

Chris

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim AESobj As Object
Dim boolResult As Boolean
Const HKEY_CURRENT_USER As Integer = &H80000001
Dim strResult As String
AESobj = CreateObject("AESRegLib.AESRegistryObject")
boolResult = AESobj.WriteString(HKEY_CURRENT_USER, "Software\Example Reg
Path", "Example String Value", "hellovb.net")
If boolResult Then
MsgBox("Write: Success")
Else
MsgBox("Write: Failed")
End If
boolResult = AESobj.ReadString(HKEY_CURRENT_USER, "Software\Example Reg
Path", "Example String Value", strResult)
'MsgBox(strResult)
'http://groups.google.com/groups?q=vb+.NET+late+bind+byref&hl=en&lr=&ie=UTF-
8&oe=UTF-8&selm=bdbb913a.0401151204.93c973c%40posting.google.com&rnum=1
End Sub
The above code work in its entirety, except the

boolResult = AESobj.ReadString(HKEY_CURRENT_USER, "Software\Example Reg
Path", "Example String Value", strResult)

It keeps giving me back " An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in
microsoft.visualbasic.dll

Additional information: Type mismatch. " .

Not sure why it's giving this, code looks fine to me. Anyone got any ideas?
The following is the working code in VB6.

Thanks


The VB6 code (working):

Option Explicit
Dim reg As New AESRegistryObject
Dim strResult As String
Dim boolResult As Boolean '
Private Sub Form_Load()
boolResult = reg.WriteString(HKEY_CURRENT_USER, "Software\Example Reg Path",
"Example String Value", "hello")

If boolResult Then MsgBox "Write : Success" Else MsgBox "Write : Fail"
boolResult = reg.ReadString(HKEY_CURRENT_USER, "Software\Example Reg Path",
"Example String Value", strResult)
If boolResult Then
MsgBox "Read result = " & strResult
Else
MsgBox "Registry read failed"
End If
End Sub
 
A

Armin Zingler

Chris said:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim AESobj As Object
Dim boolResult As Boolean
Const HKEY_CURRENT_USER As Integer = &H80000001
Dim strResult As String
AESobj = CreateObject("AESRegLib.AESRegistryObject")

Why don't you use the Registry and RegistryKey classes (namespace
Microsoft.Win32)?


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top