Passing COM Object pointers



Hello everybody,

we have a difficult problem regarding using COM Object pointers from
Matlab, which might be a Matlab bug.

We implemented a COM server in Visual Basic to expose pointers from
an automation system, which does not provide a COM interface. The COM
server itself provides two functions InitObj and GetObj. InitObj is
used by the automation system to store several object pointers in the
COM server, whereas GetObj can be called from "outside" to get access
to these pointers. This works from VB and C/C++, but not with Matlab
(R12, R13, R14). Only Matlab R11 with no SP does not show any
problems.
The following phenomenon occurs in R14 (SP1, SP2, SP3,...)

>> x = actxserver('POCom.Com')% retrieving instance of COM server

x =

COM.POCom_Com

>> c1 = x.GetObj('Class1') % retrieving instance of 1st pointer to
Class1

c1 =

Interface.C59C6B12_F6C1_11CF_8835_00A0C911E8B2

>> c2 = x.GetObj('Class2') % retrieving instance of 2nd pointer to
Class2

c2 =

Interface.C59C6B12_F6C1_11CF_8835_00A0C911E8B2

>> c1.invoke
Class1 = Variant Class1(handle)
>> c2.invoke
Class1 = Variant Class1(handle)

Both classes show 'Class1' as method, although for c2 such a method
does not exist. Instead, c2 provides the method Class2. Likewise, the
calls c1.Class1 and c2.Class1 work properly, whereas the call to
c2.Class2 issues an error.
This phenomenon might have something to do with the fact that both
COM objects are of the same interface type
('Interface.C59C6B12_F6C1_11CF_8835_00A0C911E8B2'), since two
pointers to the same interface provide the same methods.
Apparently, Matlab cannot distinguish between those two COM pointers,
since they are not registered with COM. An easy solution would be to
use a different interface name for every new pointer that is not
registered.
The fact that Matlab R11 with no SP as well as calls from VB and
C/C++ do not issue this error shows that this is a Matlab specific
problem. I do not know any possible work around.

Thanx for any help and Best Regards,
Berthold
.



Relevant Pages

  • Re: Reading C code in matlab... mex file?
    ... translate" (or matlab translate!) The following from c: ... Matlab doesn't have pointers. ... 'int nKernels' */ ... persistent FirstCall ...
    (comp.soft-sys.matlab)
  • Re: How do I reallize pointers for vairable in matlab?
    ... I thought there is not any pointer in matlab available for variables. ... Note that the help text you quoted refers to Stateflow, ... The note says that, before the file is compiled, syntax error will stay. ... There are no pointers in MATLAB itself. ...
    (comp.soft-sys.matlab)
  • Can I call a function with pointers of different type?
    ... I have a program which is originally from Matlab mex function. ... If I write the interface in general C, I try to define prhs as ... pointers while others to integer, ...
    (comp.lang.c)
  • Re: using calllib in matlab to call C structures
    ... I would like to call a C structure from within matlab. ... simple examples of the syntax on the mathworks website. ... include two pointers (or arrays of unknown size at compile time). ...
    (comp.soft-sys.matlab)
  • Re: Slow Remote 3D Performance
    ... Therefore, Matlab never talks directly to your X Server, ... thus it does not know that you have hardware OpenGL rendering. ... Matlab host you should set the DISPLAY variable to point directly to ...
    (comp.soft-sys.matlab)