LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

embed UIR in visual studio project

I have a visual studio project making use of a lab windows UIR front panel.  I know in Lab Windows you can embed the UIR file in the output executable.  However, I'm not sure how to do this when building with Visual Studio.  So how does one embed the UIR file in the Visual Studio output executable?

 

Thanks!

0 Kudos
Message 1 of 5
(4,141 Views)
I don't believe you can embed the UIR file in the executable if you're not using the CVI compiler.  That option is specified in the target settings and stored in the project file, and if you used the CVI project conversion wizard, or if you're just compiling the C files, there's no way for the Visual Studio compiler to get that information and figure out some way to embed that into the exe.  The CVI compiler adds the UIR file as a resource to the executable, and only the CVI compiler knows how to do that.
Eric B.
National Instruments
0 Kudos
Message 2 of 5
(4,114 Views)

If your ultimate goal is to avoid having to distribute the .uir file alongside your program, you do have an alternative to embedding the .uir file in the executable. Once your .uir is finalized, you can run the UI converter tool (Tools>>UI to Code Converter) to convert it to code. This tool generates the instructions that can be used to create the same UI programmatically. You then need only add this code to your project.

 

Luis

0 Kudos
Message 3 of 5
(4,084 Views)

Alternatively, you can embed the UIR in the executable, the same way that the CVI compiler does it. This, of course, is not guaranteed to work in future versions of CVI but it's worked for quite a while now. Maybe it doesn't work in CVI 2009, I haven't migrated yet.

 

You need to create a custom resource with a resource type of "UIRFILETYPE". It should have a string resource identifier which is the UIR file name that the application uses e.g. "MYGUI.UIR", and its contents are simply the (binary) contents of the UIR file. So, for example, you might end up with this code in the .rc resource file:

 

 

///////////////////////////////////////////////////////////////////////////// // // UIRFILETYPE // MYGUI.UIR UIRFILETYPE "MYGUI.UIR"

 

In this code, the first entry on the line is the resource identifier, the second entry the resource type, and the third entry the file that contains the data.

 

Pretty simple, really.

 

 

--
Martin
Certified CVI Developer
Message 4 of 5
(4,062 Views)

@msaxon wrote:

Alternatively, you can embed the UIR in the executable, the same way that the CVI compiler does it. This, of course, is not guaranteed to work in future versions of CVI but it's worked for quite a while now. Maybe it doesn't work in CVI 2009, I haven't migrated yet.

 

You need to create a custom resource with a resource type of "UIRFILETYPE". It should have a string resource identifier which is the UIR file name that the application uses e.g. "MYGUI.UIR", and its contents are simply the (binary) contents of the UIR file. So, for example, you might end up with this code in the .rc resource file:

 

 

///////////////////////////////////////////////////////////////////////////// // // UIRFILETYPE // MYGUI.UIR UIRFILETYPE "MYGUI.UIR"

 

In this code, the first entry on the line is the resource identifier, the second entry the resource type, and the third entry the file that contains the data.

 

Pretty simple, really.

 

 


Thanks for this post. I have been creating a CMakeLists.txt file to build our LabWindows 2017 product using the Microsoft compiler. I got that done, but wanted to figure out how to build-in the .uir panel files. Your post helped. I was able to build this file, and add it to the CMakeLists.txt and ... it just worked! I am not a Windows programmer, so all of this is foreign to be. If I can get it to work, it must be pretty simple!

 

# Add source to this project's executable.

set(RESOURCE_FILES "OurProgram.rc") # Your .rc file

add_executable (OurProgram ${RESOURCE_FILES}
    # Source Files:
    "src/UniversalCallbacks.c"
    "src/UniversalEEPROM_Callbacks.c"
    ...snip...
0 Kudos
Message 5 of 5
(219 Views)