LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to instantiate a COM object and call its methods using LabWindows API

I have created a COM component using Visual C++.
Here is how couple of methods look like.

1. HRESULT InitializePort([in]int nPortNum, [in]int nBaud, [in]int nParity, [in]int nDataBits, [in]int nStopBits, [in]DWORD dwCommEvents);

2. HRESULT WriteToPort([in]BSTR bstrMessage, [out]BSTR * pbstrOutput);

I would like to know how to use LabWindows APIs like CA_CreateObjectByProgIdEx, CA_CreateObjectByClassIdEx, CA_MethodInvokeV etc.

If somebody has some sample code that would be of great help.

Regards
-Murthy
0 Kudos
Message 1 of 2
(3,046 Views)
Hi,

While you can use the low-level CVI ActiveX functions like CA_CreateObject..., CA_MethodInvoke..., etc to call a COM object, it is much easier to use the CVI "Create ActiveX Controller" wizard (in the Tools menu) to create helper functions (organized like other CVI "instrument drivers") to interact with COM servers.

In order to run the wizard, you need to have a type-library for your COM server (this is normally automatically created by VC++ and in most cases embedded in the server module). Also, your server must be registered on the machine (this is again automatically done as a post-build step in VC++). So you should be able to run the wizard, and select your server from the list of registered servers in the wizard.

Also, note that you can also create
COM servers in CVI 6.0 itself using the Create/Edit ActiveX server wizards (in the Tools menu).

Regards,
Mohan,
National Instruments
Message 2 of 2
(3,046 Views)