Click here to Skip to main content
15,899,632 members
Home / Discussions / COM
   

COM

 
AnswerRe: How to write IE toolbar without ATL (on win32API)? Pin
Andy Moore6-Jun-05 8:03
Andy Moore6-Jun-05 8:03 
General"No such interface supported" returned from CoCreateInstance on successful IClassFactory->CreateInstance Pin
T-Wilson28-May-05 4:26
T-Wilson28-May-05 4:26 
GeneralMS Excel COM Interface description Pin
rantotiaray27-May-05 4:06
rantotiaray27-May-05 4:06 
GeneralVariants Pin
ursus zeta28-May-05 8:18
ursus zeta28-May-05 8:18 
GeneralRe: MS Excel COM Interface description Pin
Veera Raghavendra17-Jun-05 19:35
Veera Raghavendra17-Jun-05 19:35 
GeneralWMI and COM Pin
macakd24-May-05 12:54
macakd24-May-05 12:54 
GeneralRe: WMI and COM Pin
Member 19404227-Jun-05 3:55
Member 19404227-Jun-05 3:55 
GeneralProbably dumb question: passing IUnknown** to VB/MCPP/C# Pin
Florian Storck18-May-05 3:34
Florian Storck18-May-05 3:34 
Hi there,

while taking some first steps in programming COM interfaces, I'm stuck at some point. Here's my question:

I'm trying to add COM functionality to an existing application. Tnis application contains already a MFC Dispatch interface. My new COM interface tried to prevent in the first step using IDispatch, to have some more possibilities defining interfaces and datatypes. What I did is following:

1.) Extended the existing Dispatch interface with a function, which returns an IUnknown**, which exposes the interface to an internally created and maintained object.

2.) Created a custom interface, derived from IUnknown, which can' t be directly created and is basically used as proxy object.

Extended dispatch interface, returns pointer to existing instace of my object:
<br />
 [id(100))] SCODE GetObjRef_ppUnk([out] IUnknown**);<br />


Interface definition to be returned:
<br />
interface IMyInterface : IUnknown<br />
{<br />
    import "unknwn.idl";<br />
<br />
    HRESULT my_proc([out] myparam* p);<br />
}<br />


Working CPP code calling the OCX Control:
<br />
    #import "libid: ... my GUID ... " <br />
<br />
    LPUNKNOWN pUnk = NULL;<br />
    BOOL      bOK  = FALSE;<br />
    MyLib::IMyInterfacePtr pMyIF;<br />
    int                 iRet = 0;<br />
    MyLib::myparam  myParam = {0};   <br />
<br />
    bOK = m_myCTL.GetObjRef_ppUnk(&pUnk);<br />
    pUnk->QueryInterface(IID_IFMYIF, (LPVOID*)&pMyIF);<br />
    if(pMyIF)<br />
    {<br />
<br />
        pMyIF->my_proc(&myParam);<br />
         <br />
    } <br />


The object instance to be exposed via the interface is completely handled internally in the OCX control. Therefore, my custom interface is declared as noncreatable.

While this is working as expected in CPP , I don't get it running with VB, MCPP, C# , which I'm also not very familiar with at the moment. I tried somthing like this (Managed C++):

<br />
                 System::Object *pUnk = NULL;<br />
                 Interop::MyLib::IMyIF * pMyIF = NULL; <br />
                 Interop::MyLib::MYPARAM myParam = {0};<br />
<br />
                 <br />
                this->axMyCTL->GetObjRef_ppUnk(&pUnk);<br />
                    <br />
                 if(pMyIF)<br />
                 {   <br />
                        pMyIF->my_proc(&my_param);<br />
                 }<br />


Similar code also doesn't works in VB/C#. I suppose, it has to do with the managed thing. When calling GetObjRef I get an "An unhandled exception of type 'System.ExecutionEngineException' occurred in mscorlib.dll" . I there a legal way to accomplish this, or do I have to use the IDispatch interaces ? I searched a lot and have also the Nathan Book ".NET and COM Interoperability Guide", but I didn't found any suitable solution for my problem. The strange thing is, that the IUnknown** isn't diplayed as such in the Interop Classwrapper, but as some __MIDL_0010 type. I thought, IUnknown** can be legally used on dispatch interfaces, because its also contained in the VARIANT struct...
The basic question would be, as what kind of object the IUnknown** is handled by the underling marshaling code (if it is marshaled..).

Any helpful suggestions are very appreciated. Thanks in advance , if you read this sermon 'til this line...

Bye,
Florian
GeneralRe: Probably dumb question: passing IUnknown** to VB/MCPP/C# Pin
hanofee27-May-05 4:28
hanofee27-May-05 4:28 
GeneralRe: Probably dumb question: passing IUnknown** to VB/MCPP/C# Pin
Florian Storck27-May-05 4:43
Florian Storck27-May-05 4:43 
GeneralRe: Probably dumb question: passing IUnknown** to VB/MCPP/C# Pin
Florian Storck1-Jun-05 23:06
Florian Storck1-Jun-05 23:06 
GeneralOk. The dumbest 2 questions Pin
CherezZaboro16-May-05 4:53
CherezZaboro16-May-05 4:53 
GeneralRe: Ok. The dumbest 2 questions Pin
rwestgraham16-May-05 10:55
rwestgraham16-May-05 10:55 
GeneralRe: Ok. The dumbest 2 questions Pin
CherezZaboro16-May-05 11:01
CherezZaboro16-May-05 11:01 
GeneralRe: Ok. The dumbest 2 questions Pin
rwestgraham16-May-05 11:37
rwestgraham16-May-05 11:37 
GeneralRe: Ok. The dumbest 2 questions Pin
User 21559721-May-05 0:38
User 21559721-May-05 0:38 
GeneralDCOM and C# Pin
Millzy14-May-05 10:22
Millzy14-May-05 10:22 
GeneralSharing enums between COM objects Pin
Sir Garence12-May-05 23:52
sussSir Garence12-May-05 23:52 
GeneralRe: Sharing enums between COM objects Pin
User 21559719-May-05 21:45
User 21559719-May-05 21:45 
GeneralRe: Sharing enums between COM objects Pin
Hariharan.T19-May-05 23:14
Hariharan.T19-May-05 23:14 
GeneralGetting SafeArray** in C++ from VB COM Pin
hanofee12-May-05 22:59
hanofee12-May-05 22:59 
GeneralConverting interface pointers Pin
Mikke_x12-May-05 19:20
Mikke_x12-May-05 19:20 
GeneralRe: Converting interface pointers Pin
ursus zeta15-May-05 9:48
ursus zeta15-May-05 9:48 
GeneralStrange behavior of BSTRs in DCOM Pin
morenz12-May-05 3:01
morenz12-May-05 3:01 
GeneralRe: Strange behavior of BSTRs in DCOM Pin
Indagro12-May-05 20:54
Indagro12-May-05 20:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.