Overview
This is a simple example program for using a LabVIEW Executable as an ActiveX server.
Description
An ActiveX control is a component program object that can be re-used by many application programs within a computer or among computers in a network. In this example you create a LabVIEW executable that will act as an ActiveX server publishing data retrieved by an ActiveX client.
To create the executable and activate the .tlb file.
1. Open the ActiveX Server VI or create a VI with at least one front panel object that will host your data (numeric indicator, string indicator, etc.)
2. Create a new Build Specification and include your VI
3. Go to the Advanced section of the Build Specifications and select "Enable ActiveX Server"
4. Build the executable (EXE)
Requirements
LabVIEW 2012 (or compatible)
LabVIEW 2012 Application Builder (or compatible)
Steps to Implement or Execute Code
1- Open the project "ActiveX Server-Client_LV2012_NI Verified"
2- Browse to the location where you stored the executable and right click the application then click on Run as Administrator
2- Go to the block Diagram of ActiveX Client VI and right-click the ActiveXServer._Application Reference.
3- Select ActiveX Class » Browse... » Browse.. and select the .tlb file of your executable
4- Click Show Creatable Objects Only, then click _Application and click OK
5- Right Click the _Application Invoke Node and click on relink
6- Run the VI
Additional Information or References
Client VI:
**This document has been updated to meet the current required format for the NI Code Exchange.**
NI社区“代码范例交流区”(Example Code Exchange)中的代码范例已获得MIT许可。
Make sure the files are writeable else you'll get an error when you generate the EXE.
This example requires the source for the VI to be available.
How would you approach this if the VI isn't available?
ViPath = C:\Temp\NI\ActiveX\7276544 David Traxler\ActiveX Server.vi
controlName = Numeric
I don't get it. Why I still need to add the server VI path to the invoke node?
What if I am facing with some 3rd party executable that I don't have a VI file -- it might be a independent exe file! I am trying to ues LabVIEW show and control exe front panel, is that possible?
Thanks!
Hi Ryan,
if the .exe was built by LabVIEW you can think at it as a folder. When you get the ActiveX Automation refnum with Open Automation is like if you open the folder, then you can get access to its content. An executable built by LabVIEW can contain more than one single VI so you must specify what VI you want to control. As I know there isn't an equivalent "DIR" command to retrieve the list of contained VI. You can only obtain the full path to the open executable (methon ApplicantionDirectory and ApplicationName) but, as I know, you must know exactly the (internal) name of the VI. If the .exe is an ActiveX object built by other language when you open if from LabVIEW you can (only) use the properties and the methods it naturally expose (connect an invoke node or a property node to the refnum wire and see what you get). But if you need to take control of a general executable simulating a regular user interaction (click on button, type text, ecc...) probably the best (and only) way is to use "Call Library Function node" and interact with the native Windows API. kernel32.dll and system32.dll are full of usefull things decently documented on MSDN.
D.
If you experience error 6945 when running the Client VI, the VI path may be wrong. Check the following thread.
If you are using Windows 7, the built application does not register itself correctly if you are running LabVIEW as a normal user. Windows 7 requires administrative priveleges to write to registry. Run the created executable once as an administrator so that it registers itself correctly.
I know that this is an old post, but it directly relates to a recent post I made ActiveX-COM-control-to-LabVIEW-application
I need to create an API to my LabVIEW application. I want to run my executable simultaneously while third party application's access data in my program.
The client/server vi examples are almost exactly what I need. The problem is that I want third party applications in different languages to access my application. Would it be possible for somebody to make a simple example in a different language of the client vi?
In VBScript, python, c#, c, any other language that can work with ole/COM. When I go to 'createobject' I have no idea what COM to call. Also, I have no idea how to go about performing a VI server function call to get a VI front panel object value from outside LabVIEW. Is this even possible?
Regards,
Hi,
You must register your dll or exe file as ActiveX server in Windows.
For an exe file, it must be run 1 time with /RegServer argument to register the ActiveX server of the LabView application
To uninstall, run it 1 time with /UnregServer argument to unregister the Activex server.
If you use the Application Builder to make an installer, LabView will do it for you.
In your application builder script, you must enable 'transmit all command line arguments' and then in your application, check for presence of /RegServer or /UnregServer in the command line arguments. If one is present, exit the application immediatly.