LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way to detect the CVI runtime from a Win32 program?

I have a LabWindows/CVI application from which I will extract some functionality to be placed in a .dll. The CVI library will be run from inside a regular Win32 application. It will contain GUI elements and use the CVI C language extensions.

What's the best way to see if the CVI runtime is installed? I want to check if the runtime exists so that if the menu item that calls the CVI code is selected, it either fires up the CVI stuff or generates a message box that says you need the CVI runtime for that functionality depending on what it finds.

I'm sure I can dig around in my registry for keys to check, but I'm hoping someone out in NI-land can tell me the most robust way to go about this. I don't want to have to change my code every time NI updates CVI nor do I want my code to depend on who installed the runtime or where they installed it.

Thanks!

Dana Robinson
0 Kudos
Message 1 of 2
(2,530 Views)
Probably the simplest and also the most backwards-compatible way of doing it would be to simply attempt to load the DLL yourself and check the status:

dllHandle = LoadLibrary ("cvirte.dll")
if (!dllHandle)
; // report error
else
FreeLibrary (dllHandle);

If you don't like the idea of hardcoding the name of the CVI runtime (although it's extremely unlikely that this name would ever change) you can try loading your own CVI library instead. Your CVI library will have been built by CVI to be statically linked to the CVI runtime. So when you try to load your library using LoadLibrary, the call will fail if the CVI runtime is not present. In that case, you can simply notify the user that you could not load the CVI stuff, presumably because the CVI runtime is not present.

By the way, the CVI runtime is freely distributable, so if I were you I would always distribute the CVI runtime along with your library.

Luis
NI
0 Kudos
Message 2 of 2
(2,508 Views)