LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

COM refnum and Release of reference count

Hello,
I am writing code that accesses IVI-COM driver through the COM interfaces and there is a driver-specific property that returns IUnknown interface pointer.

When the COM object returns IUnknown interface pointer, the return value at the LabVIEW side seems like VARIANT (brown thick line) instead of Automation/COM refnum (green thin line). Then the returned VARIANT can't be wired to the Automation Close VI so that it seems like internal IUnknown::Release call is impossible. But COM servers normally increase the reference count by 1 when an interface reference is being returned to the client or just being Query-Interfaced. Who realeases the reference? In my program, actually the returned IUnknown is soon queried to oth
er concrete (known) interface such as VisaComLib::IMessage (increases the count by 1 again) but the count can be finally released (by Automation Close VI) only once (not twice).

As my thought, the reference was increased by 2 therefore Automation Close VI should be called twice. Why the IUnknown VARIANT can't be passed to the Automation Close.VI? Or any typecast needed to call Automation Close.VI?

My LabVIEW is 6.0

Thanks
Makoto
0 Kudos
Message 1 of 2
(2,642 Views)
Hi,

Some COM objects do return variants, when references are expected. If you
know what type they are, you can use "Variant To Data" to convert it.
(Sometimes they can be converted to several objects.) In LV7 you can use a
constant, in LV6 you need to create a new control with the appropriate class
(the control itself does not need to be opened, nor closed). After
convertion, the reference can be used like a normal reference, so you can
also close it.

Regards,

Wiebe.


"Makoto" wrote in message
news:506500000008000000CEC70000-1079395200000@exchange.ni.com...
> Hello,
> I am writing code that accesses IVI-COM driver through the COM
> interfaces and there is a driver-specific property that returns
> IUnknown interface pointer.
>
> When the COM o
bject returns IUnknown interface pointer, the return
> value at the LabVIEW side seems like VARIANT (brown thick line)
> instead of Automation/COM refnum (green thin line). Then the returned
> VARIANT can't be wired to the Automation Close VI so that it seems
> like internal IUnknown::Release call is impossible. But COM servers
> normally increase the reference count by 1 when an interface
> reference is being returned to the client or just being
> Query-Interfaced. Who realeases the reference? In my program, actually
> the returned IUnknown is soon queried to other concrete (known)
> interface such as VisaComLib::IMessage (increases the count by 1
> again) but the count can be finally released (by Automation Close VI)
> only once (not twice).
>
> As my thought, the reference was increased by 2 therefore Automation
> Close VI should be called twice. Why the IUnknown VARIANT can't be
> passed to the Automation Close.VI? Or any typecast needed to call
> Automation Close.VI?
>
> My LabV
IEW is 6.0
>
> Thanks
> Makoto
Message 2 of 2
(2,642 Views)