LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Calling of DLL

Hi, is it possible in labview to call a dll dynamicaly. I have a VI which
can call one of multiple dlls, at compile time i do not know what the name
of the dll will be, this is passed to the VI as a variable. I can see no
way of calling a dll (even if i know they all have the same prototye) by
variable name, can anyone help ????
0 Kudos
Message 1 of 17
(6,568 Views)
There is not LabVIEW tools to do this.
But you can use user32.dll that have functions for dll loading:
1) LoadLibraryA - load dll to memory
2) GetProcAddress - find address of some function in dll
3) Create simple CIN that get address and parameters of function and run it by pointer.
Message 2 of 17
(6,566 Views)
> Hi, is it possible in labview to call a dll dynamicaly. I have a VI which
> can call one of multiple dlls, at compile time i do not know what the name
> of the dll will be, this is passed to the VI as a variable. I can see no
> way of calling a dll (even if i know they all have the same prototye) by
> variable name, can anyone help ????
>

If there is a small set of DLLs, then you can write a VI wrapper for
each and dynamically call the appropriate VI.

To answer the original question, no, the DLL node doesn't take the DLL
or function name as parameters, these must be statically configured.

Greg McKaskle
0 Kudos
Message 3 of 17
(6,560 Views)
"Karen Breban" wrote in message
news:ap5vij$ct9$1@knossos.btinternet.com...
> Hi, is it possible in labview to call a dll dynamicaly. I have a VI which
> can call one of multiple dlls, at compile time i do not know what the name
> of the dll will be, this is passed to the VI as a variable. I can see no
> way of calling a dll (even if i know they all have the same prototye) by
> variable name, can anyone help ????
>
>
As the others stated, this cannot be done.

Another workaround might be to do the following.

Let a loader VI (a VI that loads the rest of the program) deside what dll
should be used. Copy this dll to the application directory, and give it a
general name (e.g. WorkingVersionOfDll.dll). Use this dll in the main
program. Af
ter the loader changed the WorkingVersionOfDll.dll, dynamically
load and start the rest of the program.

The loader is neccessary because LV loads the dll into memory when the VI's
are loaded. So changing the dll after this will result in a lot of trouble.

It's not very nice, but it will probably work.

Regards,

Wiebe.
0 Kudos
Message 4 of 17
(6,402 Views)
Instead user32.dll use kernel32.dll.

Sorry for mistake.
0 Kudos
Message 5 of 17
(6,569 Views)
Cheers for the help, any chance you could send me an example of how to do
this. Thanks Tom.
0 Kudos
Message 6 of 17
(6,569 Views)
Hi,

I've build set of vi's (and a small dll) to do this. Error handling is very
important. If a pointer cannot be found, you don't want to call it (jump to
NULL)!

I'll zip it and mail it to the group. Please reply to this thread, I can't
see mails with attachments, or replies to it.

There's an example. It's kinda fun to use. By changing the input for the
load function between a labview dll, and user32 dll, you use a standard
messagebox, or a custom messagebox.

There are two ways to use it. First it to store the address. By calling
CallStoredAddress with the normal input configuration of the dll, the
function is called. The second way is to call CallDll. This function assumes
that the first input is the address of the function.

Re
gards,

Wiebe.

"Karen Breban" wrote in message
news:ap9118$6be$1@venus.btinternet.com...
> Cheers for the help, any chance you could send me an example of how to do
> this. Thanks Tom.
>
>
0 Kudos
Message 7 of 17
(6,572 Views)
Hello wiebe@air,

it is possible to send me the zip file.

Thanks

Andreas
0 Kudos
Message 8 of 17
(6,568 Views)
Hello wiebe@air,

it is possible to send me the zip file.

Thanks

Andreas
andreas.schaub@systro.de
0 Kudos
Message 9 of 17
(6,568 Views)
Andreas,

It's Wiebe@Carya...

I guess you mean the dynamic dll calling files? I see if I can dig them up.

Regards,

Wiebe.

"systro" wrote in message
news:506500000005000000D9A00100-1079395200000@exchange.ni.com...
> Hello wiebe@air,
>
> it is possible to send me the zip file.
>
> Thanks
>
> Andreas
> andreas.schaub@systro.de
0 Kudos
Message 10 of 17
(6,569 Views)