PDA

Click to See Complete Forum and Search --> : dll instnaces


xyz
Jan 10th, 2002, 01:15 AM
Hi

I want to know the no of instances running for a dll.

Thanks in advance

simonm
Jan 10th, 2002, 06:15 AM
Have a general module in your DLL with a global variable. Increment it everytime your class initializes and decrement it every time your class terminates.

e.g.

Private Sub Class_Initialize()
gintInstanceCount = gintInstanceCount + 1
End Sub

Private Sub Class_Terminate()
gintInstanceCount = gintInstanceCount - 1
End Sub


NOTE:
All instances of a DLL class instantiated in the same thread will share global variables (Make sure you have a thread pool of one and not one thread per object).