Example Code

Determining the Version of an Executable Built with LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW Application Builder Module

Code and Documents

Attachment

Download All

Description

The version can be determined using the FileVersionInfo VI which, in LabVIEW 8.6 and later is found in the fileVersionInfo.llb found in the <LabVIEW 8.6>\vi.lib\Platform directory.  We recommend using this VI rather than the VI included with this document.

How to Use

For LabVIEW versions prior to 8.6, you can determine the version of an executable using Windows API calls located in the System.Diagnostics.FileVersionInfo class of the Windows System .NET assembly. An invoke node linked to the GetVersionInfo method of this class accepts an input for the path to an executable. The invoke node outputs a reference to this file's version information, which you can wire into a property node.

You can then select various properties from this property node such as FileVersion for the entire version information, as well as FileMajorPartFileMinorPartFileBuildPart, and FilePrivatePart for the respective version parts. This property node also contains properties such as ProductNameInternalProductNameLegalCopyright, and all the attributes that you can set for an executable in the LabVIEW Application Builder.  The example code for this is picture can be found below in GetFileVersion_DotNet.vi.

photo.jpg

To obtain this information for a particular executable built with LabVIEW, include a VI in the executable build that uses the Application property node properties Application»Directory Path andApplication»Name to build a path to the executable that is calling this VI.

The System.Diagnostics.FileVersionInfo class installs with the .NET Framework version 1.0 and higher. LabVIEW 8.0 requires the .NET Framework version 1.1 or higher to act as a .NET client. The .NET Framework is a free download from the Microsoft Developer Network, linked below. Refer to the attached example, GetFileVersion_DotNet.vi, for more information. 

If you want to determine the version of an executable, and your system doesn't meet the minimum requirements to use the .NET Framework with LabVIEW, then you can use traditional Windows API calls with the Call Library Function Node. Refer to the attached example GetFileVersionInfo_DLL.llb for more information on this method.

Related Links

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors