Solved

Multiple instance of an activeX EXE

Posted on 2001-07-12
4
435 Views
Last Modified: 2008-02-01
I created an activeX EXE composed of a class ClassA. This activeX is used by the applications appA and appB.
When I load the applications appA and appB they use the same instance of the activeX. And, when I stopp the application appB, it unloads the instance of the ActiveX. But like this instance is unique, the application appA (that is still loaded) is not able to work with the class of the ActiveX.

What I would like to know, it is how to load the ActiveX in the applications appA and appB so that they never use the same instance of the activeX EXE.
Either, how the ActiveX, when it is loaded could detect that there is already an other instance and how the ActiveX could create himself a second instance, independent of the first. And in this case, how unload the instance with which I work and not all instances.


any help welcome
thanks
0
Comment
Question by:Lemartna
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
jrspano earned 100 total points
ID: 6276893
go in the project properties and set the threading to thread per object.  each program will get a new instance of the active x exe
0
 
LVL 3

Expert Comment

by:jrspano
ID: 6276900
this will also take care of the unloading problem.  each exe will only unload the instance of the active x exe they have and not all of them
0
 
LVL 7

Expert Comment

by:Z_Beeblebrox
ID: 6277026
Hi,

The reason it unloads it probably because you have your class set to multiuse. Set it to 3-singleuse, then each instance will use a separate class.

Zaphod.
0
 
LVL 4

Expert Comment

by:WolfgangKoenig
ID: 6277067
You can do this with a connector class:
----------------------------------------
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Connector"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Member0" ,"RequestHandler"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"

Option Explicit

Public Property Get RequestHandler() As RequestHandler
  Set RequestHandler = gRequestHandler
End Property

Private Sub Class_Initialize()
  If gRequestHandler Is Nothing Then
    Set gRequestHandler = New RequestHandler
  End If
   
  clientCounter = clientCounter + 1
End Sub

Private Sub Class_Terminate()
  clientCounter = clientCounter - 1
  If clientCounter = 0 Then
    Set gRequestHandler = Nothing
  End If
End Sub

This you must add to your ActiveX EXE in a global
code modul:
Public gRequestHandler As RequestHandler

The object gRequestHandler guaranties that only one
instance of your AxtiveX exe is running at the same time.
The client must create a connector object, to access
the your ActiveX class with:
Set ClientActiveXRef = ClientConnector.RequestHandler

Therefore the ActiveX Exe is unloaded when the last
connector object is released ...
The idea for this is form microsoft ...

Best regards
WoK
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

910 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now