LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing COM servers. Possible?

Does LabVIEW provide a block or set of blocks for loading COM servers and calling methods in the COM server?

I'm writing the server code which LabVIEW will eventually need to interact with and I can either package my code as a COM server, or maybe in a DLL file? Does anyone have any advice or can anyone point me in the right direction where I can get information on how I can do either one?

Thanks in advance,
Arthur
0 Kudos
Message 1 of 6
(2,890 Views)
I think you'll find a lot more documentation with a slight shift in terminology. Microsoft currently uses the term ActiveX server rather than COM server, and LabVIEW does the same. This website gives a very nice description of the whole history of COM/OLE/ActiveX and how the terms have evolved:
http://www.softwaretoolbox.com/Tech_Support/TechExpertiseCenter/ObjectSoftware/ActiveXvsOCX/activexv...

Accessing an ActiveX server through LabVIEW is really quite easy, there is a palette of VIs which allow you to open a refernce to a registered server, and then call methods or access properties. There are a large amount of examples on doing this, and it is also covered in the LabVIEW Intermediate II course.

Regards,
Ryan K.
Message 2 of 6
(2,883 Views)
Arthur,

If you do indeed have an ActiveX control, using the LV ActiveX interface is definately the best way to go.

If your COM component is just a normal COM component, and it has a type library associated with it, then you can also use .NET to create what is known as a COM Interop Assembly. You can then use LV's .NET pallete to access the functionality.

There are a lot of references to creating such an assembly, but basically you would need to download the .NET SDK and then use the tlbimp tool. You don't need Visual Studio or anything.

See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cptools/html/cpgrftypelibraryimportertlbimpexe.asp for info on the tool

See http://www.microsoft.com/downloads/details.aspx?familyid=9b3a2ca6-3647-4070-9f41-a333c6b9181d&displaylang=en for the SDK.

If you have a normal COM compoent and no type library, then things get much more difficult...

Let us know what you have got and if any of this helped.

Brian
National Instruments
0 Kudos
Message 3 of 6
(2,866 Views)
Okay - I am a bit braindead. If you have LV 7 and you have a normal COM component with a type library, you should be able to use the ActiveX VIs for it regardless. We no longer require the IDispatch interface so pretty much any COM object with a typelib should work.

Brian
0 Kudos
Message 4 of 6
(2,843 Views)
My COM server is indeed a simple COM component, not an ActiveX control. I do have the type library associated with the COM component since I'm the developer of the COM server. I'll go ahead and look at the links you provided, thank you for the links by the way.

I do have one question though. You mentioned that I do not need visual studio, as you said "basically you would need to download the .NET SDK and then use the tlbimp tool. You don't need Visual Studio or anything". How would I create the "COM Interop Assembly" that you mentioned? Do I just create the COM Interop Assemply from the existing COM server which resides in a DLL by using the tlbimp tool?
0 Kudos
Message 5 of 6
(2,841 Views)
Yes, the tblimp tool takes in a type library and spits out a COM Interop Assembly. It is very straightforward.

However, in case you missed my "Braindead" post, I realized in LV 7 we added support to call the COM component directly using the ActiveX nodes. If you don't have 7.x, then you can't use the .NET stuff (wasn't added then) but you might still be able to use the COM component if you support IDispatch.

To use the ActiveX nodes, go to the Connectivity->ActiveX palette then

1. Drop an Open Automation VI.
2. Right click on the Automation reference input terminal and select Create Constant.
3. Right click on the constant node and pick "Select Class". You should then be able to browse the installed COM components.

At this point the Open should create a refnum for you that you then use via the InvokeProperty and InvokeMethod nodes.

Let me know if that works for you.

Brian
0 Kudos
Message 6 of 6
(2,833 Views)