03-26-2021 08:08 AM
Hello,
I am trying to change the Window Title of a VI when I build it into an exe. However for some reason it doesn't work.
Attached is some sample code that illustrates the problem. When I run the Pre-Build Action vi by itself it changes the title. When I use the application builder it doesn't work.
Any help would be appreciated.
Thanks
03-26-2021 08:44 AM
Hi Dan,
when my memory is correct then the AppBuilder creates a cahce of all the VIs when building the app before the PreBuild-actrion is called. Any changes made by that action will not influence that cached items.
You need to start the AppBuilder twice to implement your PreBuild-changes into the executable…
03-26-2021 10:35 AM
I can't open your project since I don't have a new enough version of LabVIEW, but what you describe should be possible. I do something similar with a pre-build action in a project that definitely works in LV 2018 SP1, though I don't modify VI properties, but instead modify the default value of a string control within a VI.
The sequence I used within the pre-build action VI goes something like:
obtain static reference to VI >> return path on disk to VI using property node >> close static reference >> read subset of text from build specification using project reference >> open a NEW reference to the VI using the path on disk >> set value of string control by name using the NEW VI reference >> "make current values default" method using the NEW VI reference >> "save instrument" method to save the VI changes using the NEW VI reference >> close reference.
I remember this being a pain to get working originally, but I don't remember the details of it anymore. Opening the NEW reference using the path on disk obtained from the static reference may have been thing thing that finally got it working for me. Its something to give a try, at least.
03-26-2021 10:46 AM
The reason for doing this is to display the rev number in the title of a built exe
Using the pre-build is a dead end.
What I did is create a vi to get the rev number and display it in the title. I run this vi on initialization
You will need OpenG and the MGI toolkit to run this vi
Works great!
03-26-2021 12:54 PM
So someone doesn't come across this thread and get the wrong impression, it IS possible to do this with a pre-build action. Attached is a working version. The main thing missing was just programmatically saving the VI after the custom title had been altered in the pre-build action.
03-26-2021 01:05 PM
03-26-2021 01:24 PM
You're welcome. Yeah they specific method is weird, something like "Save" -> "Save Instrument" is the one to pick. Could also have something to do with file permissions or user account settings.
03-26-2021 01:35 PM
Hi Dan,
@ASTDan wrote:
The reason for doing this is to display the rev number in the title of a built exe
What I did is create a vi to get the rev number and display it in the title. I run this vi on initialization
I solve this by setting a version number in the BuildSpecs (Version info -> Description).
You can read this information in your executable using the FileVersionInfo function from "vi.lib\platform\FileVersionInfo.llb\" and set the VI title dynamically inside your executable…
03-26-2021 05:03 PM
@playerm1 wrote:
So someone doesn't come across this thread and get the wrong impression, it IS possible to do this with a pre-build action. Attached is a working version. The main thing missing was just programmatically saving the VI after the custom title had been altered in the pre-build action.
When I try running it, the build fails.
03-28-2021 12:52 AM
@GerdW wrote:
Hi Dan,
@ASTDan wrote:
The reason for doing this is to display the rev number in the title of a built exe
What I did is create a vi to get the rev number and display it in the title. I run this vi on initialization
I solve this by setting a version number in the BuildSpecs (Version info -> Description).
You can read this information in your executable using the FileVersionInfo function from "vi.lib\platform\FileVersionInfo.llb\" and set the VI title dynamically inside your executable…
Whilst I would also be tempted in this case to do as GerdW describes and change the title in the running executable, you could also write a (normal, not "pre-build") VI that sets the title programmatically, and then acquires a reference to the Application Builder spec and runs it (or indeed, create your build spec from scratch and run that, but it's probably unrelated to the need you describe here).
The Application Builder VIs you're looking for for an application build-spec are probably something like:
C:\Program Files (x86)\National Instruments\LabVIEW 2019\vi.lib\AppBuilder\AB_API_Simple\Build (path).vi or
C:\Program Files (x86)\National Instruments\LabVIEW 2019\vi.lib\AppBuilder\AB_API_Simple\Build (project reference).vi
There is a polymorphic container for those two called just "Build.vi" in the same folder.
If you wanted to modify the build spec, I'd start by looking at
C:\Program Files (x86)\National Instruments\LabVIEW 2019\vi.lib\AppBuilder\AB_API\EXE\Open EXE.vi
which provides an NI_AB_API_EXE.lvclass object, and can be manipulated to adjust build specification properties/fields.
Finding the right VIs can be a bit fiddly for this API, but browsing around the AppBuilder directory and looking at the connector pane for close-sounding names can be pretty effective.
I've used these to create a cross-platform PPL building system that I'm thinking about writing up.