LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can VISA.dll be unloaded/loaded at run-time?

I want to "swap" the automatically loaded VISA.dll with my own version at run-time. I don't want to re-compile or re-link anything. I can't call UnLoadExternalModule because I don't know the module id that was assign by LabWindows to the VISA.dll.
0 Kudos
Message 1 of 8
(4,992 Views)
Are you interested in only replacing the the NI VISA DLL? If so, you can replace the visa.h with your own header file and include the type-library for your DLL in the project. This will cause LabWindows/CVI to look in your DLL for the visa functions.

Scott Y
NI
0 Kudos
Message 2 of 8
(4,977 Views)
Hi Scott,

Thanks for your response. I had assumed there was a visa.dll, but there isn't, only a static library visa.lib. Somehow, it's automatically included in the environment, it's not listed in the project file and I can't exclude. Now it would be possbile to copy over the NI visa.lib but I'd prefer not to if possible.

Any other ideas?

Thanks,

Bill
0 Kudos
Message 3 of 8
(4,966 Views)
Hi Bill,

I have attached a couple of CVI projects to more clearly demonstrate my suggestion. The Visa Test project builds an example of a replacement visa library. The Call Visa Test project shows how to include the import library, and a header file for the DLL from the Visa Test project. In this simple example, I have only implemented the int viClose(int); function. As you can see, in the Call Visa Test project, the viClose(); implemented by the Visa Test is called instead of the default.

Scott Y.
NI
Message 4 of 8
(4,955 Views)
Thanks for the examples. I ran them, but it doesn't seem like the same function signature is being used for viClose() as the one in visa.lib. If I try to make the signatures the same, the project will always use the function in visa.lib rather than my library no matter how I specify it. The implicit type conversion could have negative consequences, so without changing my code to call the new function, I'm stuck.
0 Kudos
Message 5 of 8
(4,949 Views)
Bill,

I would like to ask you for more information about your second visa.dll that you would like swap with the NI VISA DLL. Is this a DLL that you have implemented yourself, or is this a visa from another instrument manufacturer? There are some issues with using VISA from 3rd parties along with NI VISA.

Scott Y
NI
0 Kudos
Message 6 of 8
(4,908 Views)
I'm trying to replace the NI visa32.dll at run-time, first by calling LoadModuleEx and then UnloadModule. The library I want to use is one I've written that essentially will "spoof" the hardware so I can simulate it. The problem is that even though my newly loaded module has the viClose functions, etc. it still wants to use the originally loaded visa32.dll, not my replacement version. Something is still loaded or bound due to the import library visa.lib.
0 Kudos
Message 7 of 8
(4,889 Views)
Hello wkt,

When you use a function within the NI-VISA library, LabWindows/CVI automatically links in the necessary import library from cvi\bin. My initial thought about the way you should proceed is to programmatically move the visa.fp and visa.lib files out of the cvi\bin directory, then #include your custom header file at the top of your source code and your lib file in the project. Then you should be able to link to your definition of the VISA functions.

Let me know how that goes. Thanks.
Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 8 of 8
(4,866 Views)