edc
asked on
DLL Behavior
Hello all,
I have written an ActiveX DLL in VB to return some data from the registry. When I ran the DLL in the VB IDE and attached to it from an ASP page I had no problems. Once I compiled the DLL and tried to attach to it from an ASP page it acts as if the Class_Initialize() routine is not being executed. The results come back with a Count of -1. I am also able to get correct results when I create a new VB project and reference this DLL.
The class code is below
Private mvarCount As Long 'local copy
Private mvarNames As Variant 'local copy
Private mvarLocations() As Variant 'local copy
Private Sub Class_Initialize()
Dim Count As Long
mvarNames = EnumRegKeyValues(HKEY_LOCA L_MACHINE, "Software\tcg\avisoft\modu les")
ReDim mvarLocations(UBound(mvarN ames))
mvarCount = UBound(mvarNames) - 1
For Count = 0 To UBound(mvarNames)
mvarLocations(Count) = ReadRegValue(HKEY_LOCAL_MA CHINE, "Software\tcg\avisoft\modu les", CStr(mvarNames(Count)))
Next
End Sub
Public Function GetModuleName(Index As Variant) As Variant
If CLng(Index) <= UBound(mvarNames) Then
GetModuleName = mvarNames(CLng(Index))
Else
GetModuleName = ""
End If
End Function
And here is the ASP code
<% Response.Buffer = True %>
<html>
<head>
<title> ASP Test </title>
</head>
<body>
Testing Active X Object<br>
<%
Set obj = Server.CreateObject("ASReg .Registry" )
Response.Write "obj.Count = " & obj.Count & "<br><br>"
For Count = 0 To obj.Count
Response.Write "Count is " & Count & "<br>"
Response.Write "Module Name is: " & obj.GetModuleName(Count) & "<br>"
Response.Write "Module Location is: " & obj.GetModuleLocation(Coun t) & "<br><br>"
Next
Set obj=Nothing
%>
</body>
</html>
Does anyone have some insight that they can share on this?
Thanks
I have written an ActiveX DLL in VB to return some data from the registry. When I ran the DLL in the VB IDE and attached to it from an ASP page I had no problems. Once I compiled the DLL and tried to attach to it from an ASP page it acts as if the Class_Initialize() routine is not being executed. The results come back with a Count of -1. I am also able to get correct results when I create a new VB project and reference this DLL.
The class code is below
Private mvarCount As Long 'local copy
Private mvarNames As Variant 'local copy
Private mvarLocations() As Variant 'local copy
Private Sub Class_Initialize()
Dim Count As Long
mvarNames = EnumRegKeyValues(HKEY_LOCA
ReDim mvarLocations(UBound(mvarN
mvarCount = UBound(mvarNames) - 1
For Count = 0 To UBound(mvarNames)
mvarLocations(Count) = ReadRegValue(HKEY_LOCAL_MA
Next
End Sub
Public Function GetModuleName(Index As Variant) As Variant
If CLng(Index) <= UBound(mvarNames) Then
GetModuleName = mvarNames(CLng(Index))
Else
GetModuleName = ""
End If
End Function
And here is the ASP code
<% Response.Buffer = True %>
<html>
<head>
<title> ASP Test </title>
</head>
<body>
Testing Active X Object<br>
<%
Set obj = Server.CreateObject("ASReg
Response.Write "obj.Count = " & obj.Count & "<br><br>"
For Count = 0 To obj.Count
Response.Write "Count is " & Count & "<br>"
Response.Write "Module Name is: " & obj.GetModuleName(Count) & "<br>"
Response.Write "Module Location is: " & obj.GetModuleLocation(Coun
Next
Set obj=Nothing
%>
</body>
</html>
Does anyone have some insight that they can share on this?
Thanks
There is no Public Property Let Count.
ASKER
Sorry, I only posted the code that I thought was important to the problem. The entire text of the code (minus the modRegistry.bas module I have that wraps the Registry API functions).
'local variable(s) to hold property value(s)
Private mvarCount As Long 'local copy
Private mvarNames As Variant 'local copy
Private mvarLocations() As Variant 'local copy
Public Function GetModuleLocation(Index As Variant) As Variant
Dim RetData As Variant
If Index <= UBound(mvarLocations) Then
RetData = Right(CVar(mvarLocations(I ndex)), Len(mvarLocations(Index)) - 1)
RetData = Left(RetData, Len(RetData) - 1)
GetModuleLocation = RetData
Else
GetModuleLocation = CVar("")
End If
End Function
Public Function GetModuleName(Index As Variant) As Variant
If CLng(Index) <= UBound(mvarNames) Then
GetModuleName = mvarNames(CLng(Index))
Else
GetModuleName = ""
End If
End Function
Public Function GetMod() As Variant
GetMod = CVar("ModuleName")
End Function
Public Property Let Count(ByVal vData As Long)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.Count = 5
mvarCount = vData
End Property
Public Property Get Count() As Long
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.Count
Count = mvarCount
End Property
Private Sub Class_Initialize()
Dim Count As Long
mvarNames = EnumRegKeyValues(HKEY_LOCA L_MACHINE, "Software\tcg\avisoft\modu les")
ReDim mvarLocations(UBound(mvarN ames))
mvarCount = UBound(mvarNames) - 1
For Count = 0 To UBound(mvarNames)
mvarLocations(Count) = ReadRegValue(HKEY_LOCAL_MA CHINE, "Software\tcg\avisoft\modu les", CStr(mvarNames(Count)))
Next
End Sub
'local variable(s) to hold property value(s)
Private mvarCount As Long 'local copy
Private mvarNames As Variant 'local copy
Private mvarLocations() As Variant 'local copy
Public Function GetModuleLocation(Index As Variant) As Variant
Dim RetData As Variant
If Index <= UBound(mvarLocations) Then
RetData = Right(CVar(mvarLocations(I
RetData = Left(RetData, Len(RetData) - 1)
GetModuleLocation = RetData
Else
GetModuleLocation = CVar("")
End If
End Function
Public Function GetModuleName(Index As Variant) As Variant
If CLng(Index) <= UBound(mvarNames) Then
GetModuleName = mvarNames(CLng(Index))
Else
GetModuleName = ""
End If
End Function
Public Function GetMod() As Variant
GetMod = CVar("ModuleName")
End Function
Public Property Let Count(ByVal vData As Long)
'used when assigning a value to the property, on the left side of an assignment.
'Syntax: X.Count = 5
mvarCount = vData
End Property
Public Property Get Count() As Long
'used when retrieving value of a property, on the right side of an assignment.
'Syntax: Debug.Print X.Count
Count = mvarCount
End Property
Private Sub Class_Initialize()
Dim Count As Long
mvarNames = EnumRegKeyValues(HKEY_LOCA
ReDim mvarLocations(UBound(mvarN
mvarCount = UBound(mvarNames) - 1
For Count = 0 To UBound(mvarNames)
mvarLocations(Count) = ReadRegValue(HKEY_LOCAL_MA
Next
End Sub
ASKER
Adjusted points from 100 to 200
You may have to register the DLL on the PC you're running the ActiveX DLL on.
Use the REGSVR32 program to register it.
Use the REGSVR32 program to register it.
ASKER
gcs001,
Thanks for the comment. I am able to create the object, so the computer does know where to find it. I did reregister the dll anyway, but it does not change the outcome. Any other thoughts?
Thanks for the comment. I am able to create the object, so the computer does know where to find it. I did reregister the dll anyway, but it does not change the outcome. Any other thoughts?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Eureka! Thanks robbert. That did the trick.