Advertisement

09.08.2008 at 06:20AM PDT, ID: 23711910 | Points: 500
[x]
Attachment Details

C++ ATL parameter question

Asked by cuziyq in Windows ATL / WTL / COM Programming, C++ Programming Language, Microsoft Visual C++

Tags: , ,

I have a simple ATL object which contains a function that looks like this:

Object1::Function(Object2 * obj2, long * retval)
{
      obj2->Property = 5;
      *retval = 1;
}

From my front-end code, I call it like this:
...
{
      ATLLib::Object1Ptr * obj1;
      ATLLib::Object2Ptr * obj2;
      long prop, retval;

      retval = obj1->Function(obj2);
      prop = obj2->Property;
}

Now, when the function gets called from the front end, the retval makes it out OK, but the property from Obj2 does not.  The only explanation for this is that a copy of Object2 is being passed in, not its pointer.  This is despite the fact that a pointer is clearly defined as an argument to the function.  There's some kind of funky indirection thing that ATL does that I don't understand -- like also not having to pass a reference to retval even though the function itself takes it as a parameter.

What's going on here?  How do I get the value of that property back out of the ATL function?Start Free Trial
[+][-]09.08.2008 at 09:30AM PDT, ID: 22419015

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906