Solved

Multiple instance of an activeX EXE

Posted on 2001-07-12
4
450 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
[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
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb6 connector to mongodb 2 163
Error when passing an argument to a vb6 that contains  '/' 7 49
checkbox to hide entire section 10 76
Set WorkSheet  not Working 9 62
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

751 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