Click to See Complete Forum and Search --> : ActiveX


Gowri Sankar. J
October 29th, 1998, 02:02 AM
Is it possible to have a variable in Active X Server which has the no of

references to it stored?

vmkrish
September 8th, 1999, 06:48 AM
It's Quite possible in Out-Of-Process Component(That's EXE Server).

When You develop your component as Out-Of-Process component then(EXE Server),You Have the advantage of Global Data Sharing.

In your Project Add A Standard Module(Module File)
and Declare a Public Variable Of Type Integer/Long.

In all Classes in your component in the Class_Initialize Event Increment the Value of the Variable and In the Class_Terminate Event Decrement the value of the Variable.

And in all Classes add A Function that returns that Variable(Module Variable That holds Count of Object Refs).


That's All.

Sent Your comments to vmkrish@yahoo.com

Vinayak Sapre
September 12th, 1999, 02:39 PM
vmkrish's solution will work only if the the ActiveX exe is set to thread pool with number of threads = 1 in project options. In other words it's single threaded EXE. If that EXE is multithreaded then the count returned will be number of objects on the thread where the object in use is placed. Not all objects created by the EXE on different threads. Same applies for DLL. Note that DLL objects are created on the client thread.

The thumb rule is global is with respect to the thread not server.

The easiest and reliable solution to share data is memeory mapped files. Avoid using registry / disk files as if app terminated abruptly for some reason there is no way to cleanup registry or disk file. One more advantage of memory mapped files it works system wide. Meaning that's a reliable way of sharing data between the applications on the same machine.

Download source code for Hardcode VB. It has the class written to deal with memeory mapped files.