OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
From: Tim Tabor (tltaborEARTHLINK.NET)
Date: Tue Jun 05 2001 - 18:27:47 CDT

  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

    Sure you can pass out an interface* from an object you've created
    internally. But the recipient needs to marshal the pointer before
    using it in a different apartment. This is the same whether the
    object is activated w/ CCI or CreateInstance.

    // tim

    > -----Original Message-----
    > From: Distributed COM-Based Code [mailto:DCOMDISCUSS.MICROSOFT.COM]On
    > Behalf Of Vimal Kumar
    > Sent: Tuesday, June 05, 2001 4:50 PM
    > To: DCOMDISCUSS.MICROSOFT.COM
    > Subject: CoCreateInstance(Ex)...do we really need to use it ?
    >
    >
    > Thanks to all you guys for your prompt reply. Atleast now I can
    > say that if
    > all objects are in the same DLL and they are used from C++ client, I can
    > create the objects internally using new or CComObjectXX::CreateInstance().
    > Can I hand this pointer out to any other clients ( assuming I AddRef() ??
    > The reason I ask is, suppose I spawn a thread from my interface
    > method, call
    > CoIntialize(Ex) on that thread, and then execute some interface methods on
    > that thread - is it fine ? How will COM understand about marshaling the
    > interfaces ? I didn;t create the object using CoCreateInstance(Ex).
    >
    > Is there a proper document that explains the working right from the
    > CoInitialize(), CoCreateInstance()...to CoUnInitialize() ?
    >
    > Thanks again for all your help.
    >
    > -Vimal
    > ----- Original Message -----
    > From: "Leon Finker" <lf21NETZERO.NET>
    > To: <DCOMDISCUSS.MICROSOFT.COM>
    > Sent: Tuesday, June 05, 2001 7:38 AM
    > Subject: Re: CoCreateInstance(Ex)...do we really need to use it ?
    >
    >
    > > Hi,
    > >
    > > The hidden window is created per STA apartment and not
    > > per object in that apartment. So, it should be created when
    > > apartment is entered and initialized, which is at CoInitialize(Ex)
    > >
    > > ----- Original Message -----
    > > From: "Vimal Kumar" <vimalnCSWL.COM>
    > > To: <DCOMDISCUSS.MICROSOFT.COM>
    > > Sent: Monday, June 04, 2001 11:15 PM
    > > Subject: CoCreateInstance(Ex)...do we really need to use it ?
    > >
    > >
    > > Back to some basic question. I am sure this question has been asked in
    > > several different ways but even after going through the list archives I
    > > could not find a valid answer to my question.
    > >
    > > The following scenarion describes the problem.
    > >
    > > I have 2 inproc object viz 'A' & 'B'
    > > From my client code I call CoInitialize(NULL)
    > > I call CoCreateInstance(..."A" )
    > > A->CreateBObject(); // CreateBObject creates an instance of
    > object B and
    > > keeps a reference to IB
    > > Should I use CoCreateInstance to create object B ? What wrong can happen
    > if
    > > I use "new" instead of CoCreateInstance ?
    > > Both A & B are implemented by the same server.
    > > Does CoCreateInstance() do anything other than (a) Get the CLSID from
    > > registry (b) find the corresponding DLL from InProcServer32 key (c) Load
    > the
    > > dll & call DllGetClassObject() (d) Call CreateInstance on the class
    > factory
    > > object.
    > >
    > > Who creates OleMainThreadWndName hidden window ? Is it CoInitialize() ??
    > >
    > > Ahh....I am confused !!!! Help me..
    > >
    > > -Vimal
    > >
    > >
    > >
    > > ----------------------------------------------------------------
    > > Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
    > > contains important info. Save time, search the archives at
    > > http://discuss.microsoft.com/archives/index.html .
    > > To unsubscribe, mailto:DCOM-signoff-requestDISCUSS.MICROSOFT.COM
    > >
    > > ----------------------------------------------------------------
    > > Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
    > > contains important info. Save time, search the archives at
    > > http://discuss.microsoft.com/archives/index.html .
    > > To unsubscribe, mailto:DCOM-signoff-requestDISCUSS.MICROSOFT.COM
    >
    > ----------------------------------------------------------------
    > Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
    > contains important info. Save time, search the archives at
    > http://discuss.microsoft.com/archives/index.html .
    > To unsubscribe, mailto:DCOM-signoff-requestDISCUSS.MICROSOFT.COM

    ----------------------------------------------------------------
    Users Guide http://msdn.microsoft.com/workshop/essentials/mail.asp
    contains important info. Save time, search the archives at
    http://discuss.microsoft.com/archives/index.html .
    To unsubscribe, mailto:DCOM-signoff-requestDISCUSS.MICROSOFT.COM