4

I am using a third-party application, and making a call to create an instance of my COM object. This call is succeeding, however the function on the third-party application does not return a pointer to the created object (I have no idea why). Is there any way to get a pointer to my object?

To clarify, here's some pseudo-code:

// This function has no return value!
ThirdPartyApp.CreateObject("MyObject");
4
  • What is the third party library called? Commented Jan 7, 2009 at 22:06
  • What language are you programming with? Commented Jan 7, 2009 at 22:13
  • Incidentally, how does this other app get a reference to your object? I mean, why does it create it if it can't use it? Commented Jan 7, 2009 at 22:14
  • @willcode OSIsoft's ProcessBook API @j0rd4n C# @Rob It's adding my COM object to its display--presumably it's keeping a reference to my object internally. Commented Apr 14, 2009 at 21:19

2 Answers 2

2

When your object is created, make it store a reference to itself in a global variable or some other sort of shareable storage location. Then export a function from your COM DLL that will read from that location so you can call it and get a reference to the previously created object.

This shared reference should not increase the reference count of the object, or else it will never get destroyed. When your object gets destroyed, make sure you clear that shared reference.

If you can have more than one instance of this object in the same process, then you may need to manage a list instead of just a single global variable.

Sign up to request clarification or add additional context in comments.

Comments

0
  1. Store your return value HRESULT (is this C++?), it may yield a clue.
  2. Sometimes there are sneaky tricky marshalling/creation problems if you are calling a factory-type object which exists in another apartment.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.