Board index » delphi » Objects as parameters in COM method calls

Objects as parameters in COM method calls

I am having problems understanding the correct
way to pass objects as parameters in a method
call to a COM object. For a (relatively) simple
example of what I want to do...

I want to store a number of TOracleQuery
components in an automation object (in a DLL). I
will have several of these DLLs to use in my
final application, so to save on resources, I
want to have only one TOracleSession, on the main
form of my EXE. My plan is to create instances of
each automation object (as 'in process servers')
when required, and retrieve data from the Oracle
Queries via Automation events, passing integers
and wide strings back to the calling form. My
problem is that the OracleQuery requires a
session parameter, which I would like to set at
run time. I thought that I could create a method
in my automation object which took the session
object as a parameter (or at least a pointer to
the Session), but am not sure how to do this.
What is the COM compatible type for passing
objects (or pointers to objects)? I am new to
COM, so please accept my apologies if the
question makes no sense at all!

Sent via Deja.com http://www.deja.com/
Before you buy.

 

Re:Objects as parameters in COM method calls


What I meant to say was that the Object you want to pass as a param
better implement Idispatch or Iunknown. Preferably Idispatch because then
you get the marshalling for free.

Check out Microsofts web site for more info.

Quote
>>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<

On 7/20/2000, 12:50:36 PM, Tom Willis wrote regarding Re: Objects as
parameters in COM method calls:
Quote
> The safest way to pass objects as params in functions defined in your
> type library  is to pass them as Olevariants. Then on the inside cast the
> variant to the object you expect. The trick is the Object has to be able
> to be marshalled. So your object better implement Idispatch or Iunknown
> or it won't work.
> >>>>>>>>>>>>>>>>>> Original Message <<<<<<<<<<<<<<<<<<
> On 7/20/2000, 11:31:41 AM, orf...@my-deja.com wrote regarding Objects as
> parameters in COM method calls:
> > I am having problems understanding the correct
> > way to pass objects as parameters in a method
> > call to a COM object. For a (relatively) simple
> > example of what I want to do...
> > I want to store a number of TOracleQuery
> > components in an automation object (in a DLL). I
> > will have several of these DLLs to use in my
> > final application, so to save on resources, I
> > want to have only one TOracleSession, on the main
> > form of my EXE. My plan is to create instances of
> > each automation object (as 'in process servers')
> > when required, and retrieve data from the Oracle
> > Queries via Automation events, passing integers
> > and wide strings back to the calling form. My
> > problem is that the OracleQuery requires a
> > session parameter, which I would like to set at
> > run time. I thought that I could create a method
> > in my automation object which took the session
> > object as a parameter (or at least a pointer to
> > the Session), but am not sure how to do this.
> > What is the COM compatible type for passing
> > objects (or pointers to objects)? I am new to
> > COM, so please accept my apologies if the
> > question makes no sense at all!
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

Other Threads