Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ActiveX reference count

Posted on 1998-01-21
4
Medium Priority
?
322 Views
Last Modified: 2013-12-03
Hello, I checked the following structure:
console application(process 1) call ActiveX exe(process 2), I'll call it exe1.
the ActiveX exe call ActiveX dll, I'll call it dll1, the dll call a nother ActiveX exe, called exe2.

reference count is r.c.

1. r.c in console for exe1 is 1 and in exe1 it is 4, why ?
2. passing this from exe1 to dll to exe2 and assigning a smart pointer to it increase r.c to exe by 2 and both exe and exe2 stay up. why ?
3. like 2, only the passed argument to exe2 is this from the dll. this time none of the processes stays, but r.c count jumps from 1 to 4 (the dll count) in the dll.

so, the problem is how do the r.c done between processes
and in them ? when a process will stay up ?

many thanks,
   Gilad
0
Comment
Question by:gilad111397
[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
  • 3
4 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 480 total points
ID: 1410216
An object cannot be terminated or shut down while there are references to it.

Or until all references to an object are released, the object will continue to live.

So there can be a situations where if an object has a reference to another object and that object has a reference to the original object, then they cannot shut down properly. The only way around this is to hard code one of the objects so that when a request to shut down comes in, the object shuts down regardless of the reference count.

Normally, if you have two objects that must do this, it is better to create a third object which is a manager object. The manager object that passes out resource references to the original objects. This way, the objects don't hold reference counts to each other, but to the manager object. Makes shutting down much easier.


0
 

Author Comment

by:gilad111397
ID: 1410217
Ok, suppose we use an object manager which hold two ActiveX exe objects (exe1 and exe2). When exe1 wants to refer exe2, the manager send to it a pointer to exe2. When I assign a smart pointer (IDispatchPtr, for instance) to the argument which was received from the manager (IDispatch *), that's it, the processes will stay up.
What is wrong here ?
0
 

Author Comment

by:gilad111397
ID: 1410218
The smart pointer is defined as global variable.
0
 

Author Comment

by:gilad111397
ID: 1410219
Also, last clarification, I read about CoMarshalInterface, Is it recommended to use it ? if yes, then when I use LPSTREAM, I understand it should be moved to the other process and it would use CoUnMarshalInterface. How do you recommend to send this LPSTREAM ?

thanks a lot.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

722 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