Yes, it is possible. The default behavior of an ActiveX exe is to have every application that creates a reference to your exe share a single instance of it in a single process. If you want to change this so that each reference creates its own separate exe in a separate process, then change the Instancing
property from MultiUse
to SingleUse
.
You can't do this programmatically at runtime; you have to do it in the IDE. In the Project window, click on the class, and you'll see the Instancing
property in the Properties window.
Another thing you may want to experiment with as a possible alternative is the threading model. The default, again, is one process handling all references (MultiUse) but also a single thread handling all references. To change this, you can go into the Project properties (bottom selection on the Project menu) and look at the Threading Model area in the lower right of the dialog box.
The default is a thread pool with one thread. If you change this to "thread per object" you will create a new thread each time you create a reference to your ActiveX Exe. You can also change the thread pool number to add more threads to it. If you do this, the threads are assigned on a round robin basis: if you have, say, five threads in your pool and six instances, two of the instances (VB won't tell you which, so beware) will share the first thread.
So, if you need multiple instances of your EXE, then change the instancing
property to SingleUse
. But if you are looking to enhance performance and execution time, you might find that multiple threads in one process is something to investigate as well.