Solved

DLL Behavior

Posted on 2000-03-30
7
257 Views
Last Modified: 2009-12-16
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_LOCAL_MACHINE, "Software\tcg\avisoft\modules")
    ReDim mvarLocations(UBound(mvarNames))
    mvarCount = UBound(mvarNames) - 1
    For Count = 0 To UBound(mvarNames)
        mvarLocations(Count) = ReadRegValue(HKEY_LOCAL_MACHINE, "Software\tcg\avisoft\modules", 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(Count) & "<br><br>"
      Next
      Set obj=Nothing
      
%>
</body>
</html>

Does anyone have some insight that they can share on this?

Thanks
0
Comment
Question by:edc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 15

Expert Comment

by:robbert
ID: 2670331
There is no Public Property Let Count.
0
 
LVL 1

Author Comment

by:edc
ID: 2670354
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(Index)), 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_LOCAL_MACHINE, "Software\tcg\avisoft\modules")
    ReDim mvarLocations(UBound(mvarNames))
    mvarCount = UBound(mvarNames) - 1
    For Count = 0 To UBound(mvarNames)
        mvarLocations(Count) = ReadRegValue(HKEY_LOCAL_MACHINE, "Software\tcg\avisoft\modules", CStr(mvarNames(Count)))
    Next
End Sub
0
 
LVL 1

Author Comment

by:edc
ID: 2670844
Adjusted points from 100 to 200
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 4

Expert Comment

by:gcs001
ID: 2672998
You may have to register the DLL on the PC you're running the ActiveX DLL on.
Use the REGSVR32 program to register it.
0
 
LVL 1

Author Comment

by:edc
ID: 2673188
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?
0
 
LVL 15

Accepted Solution

by:
robbert earned 200 total points
ID: 2673444
Ahhh, I know. Obvious.

When you call the component from a web page, you're running it under the iusr_machinename account. This account doesn't have the permissions to read the registry.

To run the component under an administrator's account, create an MTS package for it:

- In MTS Explorer, expand the tree on the left and, select Packages Installed. Menu: Action | New | Package.
- Dialogue: Create Empty Package, specify the account to run under.
- Expand the newly created Package, select Components.
- Menu: Action | New | Component
- Select your component.

That's it. Now, you can right-click the Package and, edit some additional properties.
0
 
LVL 1

Author Comment

by:edc
ID: 2673660
Eureka!  Thanks robbert.  That did the trick.
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question