LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to call a function with the same name from 2 different dll's at the same time.

I'm trying to call a function ( F ) form 2 different libraries ( A.dll and B.dll ) at the same time. The first lib loaded determines the function F. A->F and B->F have same interface and name but different implementation.
0 Kudos
Message 1 of 10
(3,369 Views)
rsam;

I'll say, try it and let us know the result!

My guess is that you can. In LabVIEW, when you use the call library function, you need to specify the full path of the library.

Regards;
Enrique
www.visecurity.com
www.vartortech.com
0 Kudos
Message 2 of 10
(3,369 Views)
Well, now I have a question: The .dlls has the same names too?
www.vartortech.com
0 Kudos
Message 3 of 10
(3,369 Views)
When the two dll's have different names you should not have any problems to do this. If they have you probably will run into problems since LabVIEW allready has a dll loaded with the same name. It will most likely not load the second dll.

Best regards,

RikP
Application Engineering
National Instruments
Rik Prins, CLA, CLED
Software Development Engineer
0 Kudos
Message 4 of 10
(3,369 Views)
RikP wrote:

> When the two dll's have different names you should not have any
> problems to do this. If they have you probably will run into problems
> since LabVIEW allready has a dll loaded with the same name. It will
> most likely not load the second dll.

It can't! Windows does not allow to map two executable files with the
same file name into the same process space. As such it is very similar
to how LabVIEW works with two different VIs with the same name, which
can't be loaded into the same LabVIEW system at the same time.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 5 of 10
(3,369 Views)
Hi,

If I understand correctly, you want to load one dll (A or B), and use the
function in this one? This can be done in different ways. To name a few:

a) Make a VI wrapper for each function. Put them in two labview libraries
(A.llb, B.llb), and load the desired library dynamically.

b) Make a wrapper that has a case to swich between dll A or B. Use an input
parameter to deside which one to use.

c) Load the dll's dynamically, and get a pointer to the function in A or B.
Use a dll (e.g. made in C) to call this function.

Regards,

Wiebe.




"rsam" wrote in message
news:50650000000800000073F00000-1079395200000@exchange.ni.com...
> I'm trying to call a function ( F ) form 2 different libraries ( A.dll
> and B.dll ) at the same time. The first lib lo
aded determines the
> function F. A->F and B->F have same interface and name but different
> implementation.
0 Kudos
Message 6 of 10
(3,369 Views)
Here'the catch; Labview references function by name(assumed) Only 1 function can be loaded at a time with a given name. I want to load 2 functions with the same name from different library at the same time. I'm not able to do that in labview. Somehow i've to create my own namespace tag to control the function selected.

Does anybody else has some input on this matter?

Thx Ruud
0 Kudos
Message 7 of 10
(3,369 Views)
Hi,

Your assumption is not correct (or not accurate). LabVIEW does not reference
external functions by name. The module (dll or exe or ocx) is loaded by
name, and the function inside it is referenced with a pointer.

To check this, I created my own MessageBoxA function inside a dll. I called
this at, and the user32 MessageBoxA at the same time. They appear
simultaneously.

Regards,

Wiebe.

"rsam" wrote in message
news:50650000000500000004C40100-1079395200000@exchange.ni.com...
> Here'the catch; Labview references function by name(assumed) Only 1
> function can be loaded at a time with a given name. I want to load 2
> functions with the same name from different library at the same time.
> I'm not able to do that in labview. Someho
w i've to create my own
> namespace tag to control the function selected.
>
> Does anybody else has some input on this matter?
>
> Thx Ruud
0 Kudos
Message 8 of 10
(3,369 Views)
Thx Wiebe,

did you load both dll at the same time? For example in 1 vi. Somehow the first loaded function keeps to overrule the second. Notice that the interface is exactly the same.

I loaded 2 dll created in Labview with results described above.

Regards Ruud
0 Kudos
Message 9 of 10
(3,369 Views)
Hi,

I tried it with two dll's, both with the same interface, and at the same
time, in the same VI. The popups even appear at the same time.

But now I understand the problem... Both dll's are created by LabVIEW! If
they are not (or one is not, and the other is), this is no problem.

And VI's in memory cannot have the same name. LabVIEW doesn't care if VI's
are in a dll or not.

This might not help, but if you want to make some sort of "plug in" system,
you might consider using llb's. By loading VI's dynamically, you can select
the path from which they are loaded. You must unload (close all references)
one before the loading the other, or the same problem will occur. If you go
this way, I consider a different approach. Make on
e library (or even a dll)
that has the interface you like, this is the "loader". Now make several
"plug in"'s, with the same interfaces. The name of each function in a plug
in is a concatenation of the library name and the function name. The loader
has one extra function, that loads (and unloads, when done) references to
all desired libraries to use (the names of the functions can be figured out
easily). All that the loader functions do is dynamically call the library
functions. You can use a call by reference node for this (you can use the
connector pane or the loader vi, since the interface must be the same!).

If you go this way, I guess the loader library can be converted to a dll...

Hope this helps.

Wiebe.

"rsam" wrote in message
news:50650000000500000087C40100-1079395200000@exchange.ni.com...
> Thx Wiebe,
>
> did you load both dll at the same time? For example in 1 vi. Somehow
> the first loaded function keeps to overrule the second. Notice that
> the interface is
exactly the same.
>
> I loaded 2 dll created in Labview with results described above.
>
> Regards Ruud
0 Kudos
Message 10 of 10
(3,369 Views)