Solved

Multiple instance of an activeX EXE

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Validating VB6 Function 19 65
String manipulation in Visual Basic 7 73
Prevent user closing word document opened with VB6 6 78
Help me. 3 60
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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

830 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