troubleshooting Question

ActiveX DLL - separate instances of linked library

Avatar of jersa
jersa asked on
C++Visual Basic ClassicProgramming Theory
5 Comments1 Solution566 ViewsLast Modified:
I've got a VB  ActiveX object which links to a separate DLL (VC++ based). When I create multiple instances of the ActiveX object from within the same program, I get true, separate instances (all the properties are separate, as they should be). However, I really need the DLL that I'm linking to also be truly separate instances of that DLL but I can tell they are not (based on values stored by the DLL)

Internal to my VB Class, I've got:

' "mycall" is an entry point in mycpp.dll
Private Declare Function mymath Lib "mycpp.dll" Alias "mymath" (ByVal info As String) _
     As Long

' the public version to access that library
Public Function doMath(ByVal info As String) As Long
    doMath = mymath(info)
End Function

' and a property...
Private myInternalProp As String
Public Property Let someProp(value As String)
    myInternalProp= value
End Property
Public Property Get someProp() As String
    someProp = myInternalProp
End Property
If I then instance two copies of this object from a separate VB application (for example)
Dim obj1 As myTools.application
Dim obj2 As myTools.application
Set obj1 = New myTools.application
Set obj2 = New myTools.application

obj1.someProp = "first instance"
MsgBox(obj2.someProp)  'shows empty, thus unique copy of "application"
result1 = obj1.doMath("...")
result2 = obj2.doMath("")    'result2 shows that this called into the same DLL
The "someProp" value is clearly separate between the two objects, but the doMath is calling the SAME instance of the DLL (the DLL saves some values and I can tell from the output of "domath" that it is the same call)

However, if I split obj1 and obj2 and their corresponding calls into two separate VB applications, they are completely separate (doMath clearly calls a separate .dll copy)

Is there some way from the VB side to force each instance of the ActiveX accesses a different copy of the mycpp.dll?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros