Solved

Multiple instance of an activeX EXE

Posted on 2001-07-12
4
430 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

760 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