Passing COM Object pointers
- From: "Berthold Barzantny" <Berthold.Barzantny@xxxxxx>
- Date: Tue, 24 Jan 2006 06:00:20 -0500
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
.
- Prev by Date: Re: #include
- Next by Date: MATLAB different results from release to release
- Previous by thread: Re: 3D bar charts with no markers for zero entries
- Next by thread: MATLAB different results from release to release
- Index(es):
Relevant Pages
|