From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get the application build version into my VI?

I'm using app builder to create an exe for my customer.  I want to put the build version number (major.minor.fix.build) into my front panel VI (to make customer support easier).  How can I get it?  Sure, I could hard-code a string in my VI, but then my source code changes every time I do a release.  Surely there's a way to get it without changing the source code.

 

0 Kudos
Message 1 of 7
(14,816 Views)

Take a look at this code here, it should do what you want:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

This code is from the NI Developer Zone.

 

Message Edited by jmcbee on 03-18-2009 11:55 AM
Message Edited by jmcbee on 03-18-2009 11:57 AM
Message 2 of 7
(14,808 Views)

Another option if you are using LabVIEW 8.6 (I'm not sure if its included in 8.5 or not) is to use the VI found in vi.lib\Platform\FileVersionInfo.llb\FileVersionInfo.vi

 

As far as I am aware, this uses the built in APIs of the platform in question (ie win32 for Windows) and does not rely on .NET being present on the development or target machine.

Message 3 of 7
(14,789 Views)

Nice jmcbee !

And this is modified. It's more handy

Message 4 of 7
(14,781 Views)

Try this on for size... I went a little bananas and made a VI that can not only get the build version when the VI is in an executable, it can ALSO extract the build version from a specified project that is currently open when in source mode. It also has decent error reporting too.

 

 

Easy to use:

Use.png

 

Voila! Update the build version in the project, and it updates in your application no matter how you're running it. I converted to LabVIEW 8.6 so almost anyone can use this.

Message 5 of 7
(11,159 Views)

For the past few versions of LabVIEW, NI has provided Get Build Specification Version and Set Build Specification Version, found either in the Application Builder sub-folder of the Application Control Palette, or downloadable from the LabVIEW Tools Network as part of the Hidden Gems in VI.lib.

 

I tend to "hand-code" Major, Minor, and Fix versions (actually, I set them once and rarely change them, except when I mean to go from Version 1.1 to 1.2, of course), and for the Build, I use the current Revision Number of the Subversion Repository where the LabVIEW Project is saved.  To automate updating ("Setting") the Version Number at Build Time, I used a Pre-Build Action that asks Subversion for the Revision Number and stuffs that into the Build slot.

 

Of course, there's a "Feature" (a.k.a. a Bug) that makes this not work as you'd expect.  When you first build your executable, the Build number is cached (by NI), the Pre-Build Action updates it, then NI builds the executable with the (now incorrect) cached version.  Solution -- build twice.  Better solution -- fix the Application Builder to let Pre-Build Actions take place before (the plain meaning of Pre-) the Build.

 

I have an Idea Exchange asking NI to consider fixing this here.  Consider Kudo-ing it if you think this is something NI should consider.

 

Bob Schor 

Message 6 of 7
(11,151 Views)

@Mercuri

 

Thanks this was exactly what i was looking for and it works great.  I had been trying the VI by G-Money listed in -> http://forums.ni.com/t5/Example-Programs/Get-LabVIEW-Executable-Version-Programmatically/ta-p/352056... but any time i would move it into my own program it would stop working, but would work fine in his example project when compiled.

 

This is because G-Moneys VI only works if it is in a folder in a higher level or the same level as the root VI file at compile time. Otherwise it throws an error. Meanwhile, your code edits the path to the executable level, so its fine in a sub folder.

 

Text Edit.png

 

Once again great job Mercuri. Going to keep this one as one of my regular VI's to have on hand for future projects.

 

0 Kudos
Message 7 of 7
(10,989 Views)