LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to obtain an IUnknown pointer from an ActiveX object

I am very new in ActiveX and also just getting familiar with COM (Component Object Model).
How can I obtain an IUnknown pointer from an ActiveX object?

my code is:
------------------------------
//some variables:

    FdtType_FdtXmlDocument SupportedProt = 0;
    IUnknown *interfacePtr;

    HRESULT error;
    CAObjHandle TCICommSrv;
    ERRORINFO errorInfo;

//the code part:

   DisplayPanel (panelHandle);
   
    CA_InitActiveXThreadStyleForCurrentThread(0, COINIT_APARTMENTTHREADED);
   
    error = CA_CreateObjectByProgIdEx("TCI.SimaticCommunicationServer.1", NULL, &IID_IUnknown, 1, LOCALE_NEUTRAL, 0, &TCICommSrv);

    CA_GetAutomationErrorString (error, buffer, buffersize);
    CA_DisplayErrorInfo(TCICommSrv, "error info", error, 0);
   
    CA_ServerQueryInterface(interfacePtr, &Fdt_IID_IFdtCommunication, &newInterfacePtr);
   
  //end code

As far as I know the QueryInterface method is for gathering the interfaces supported by the ActiveX server? Am I right?
That is why I seek for if the implemented interface (Fdt_IID_IFdtCommunication) exists? So at this point I don't know
what should be the first parameter (interfacePtr) for this QueryInterface function. Somehow the interfacePtr is not good.

Thanks,
Roland
0 Kudos
Message 1 of 3
(3,722 Views)
Use CA_GetInterfaceFromObjHandle instead of CA_ServerQueryInterface. The CA_ServerQueryInterface library function is for use in CVI-created COM server programs. Your program is a COM client and to get the IUnknown (or any other) interface from the external COM server object, you should use CA_GetInterfaceFromObjHandle.
0 Kudos
Message 2 of 3
(3,695 Views)
Mohan,

thank you for your answer, indeed it helped.  Smiley Wink

Roland
0 Kudos
Message 3 of 3
(3,668 Views)