LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW call CVI daisy chained DLL fail

Solved!
Go to solution

Hi

    Daisy chained DLL: DLL A and DLL B, DLL A use LoadLibrary to load DLL B.

   I have created a dll in Labwindows CVI. In this dll I dynamically call another dll using LoadLibrary function. This dll works fine when I call DLLA in labwindows cvi and I get right return value(the return value was computed by DLL B).

   When using labview , the call Iibrary funtion node run smoothly and the error out with no error, but the return value always 0, sames that labview load DLL A successfully , but DLL A can't load DLL B using LoadLibrary function so that return value always 0. Any idea why?(DLLA and DLLB under same directory)

   for example; I have created dllA.dll in cvi. In dllA.c I have code like this

        dll_handle = LoadLibrary ("DLLB.dll");

       if(dll_handle == NULL) {

            MessagePopup ("ERROR", "LIB2.DLL Load Error"); return -49;

         }

       return DLLB_FuncGetValue();

using labwindows I can call dllA.dll and it successfully loads DLLB.dll.

0 Kudos
Message 1 of 3
(2,529 Views)

Did you try calling GetLastError() after LoadLibrary() to get more information about the failure?

0 Kudos
Message 2 of 3
(2,495 Views)
Solution
Accepted by topic author topkinschen

And where did you put down your DLL_B.dll?

 

Since you do not provide a path to the LoadLibrary() function, the standard Windows search criteria apply. Generally it comes down to the fact that that DLL has to be in one of these locations if you do not provide a full (and valid) path:

 

1) if it is already loaded in the process that one is used directly and only the usage counter is incremented.

2) Check the directoy where the executable program for the current process is located (for LabVIEW IDE this is C:\Program Files (x86)\National Instruments\LabVIEW <version>\

3) Check Windows directory

4) Check System directory

5) Check all directories listed in the PATH environment variable

 

Whenever the load was successful the usage counter is incremented and calling FreeLibrary() for the same DLL will decrement the usage counter until it reaches 0 and then the DLL is unloaded for the current process (It still could be loaded by Windows for other processes).

 

Your code calling LoadLibrary() every time when the function is called is suboptimal. You should make the DLL handle variable static and only load the library when this static variable is NULL.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 3 of 3
(2,463 Views)