LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading exported variables from DLL

Dear Community,

I am trying to read a variable that is exported by a third-party DLL inside a LabView VI. If it were a function, then I would just use a "Call Library Function" subvi. But it's not a function; it's a variable, something like

__declspec( dllexport ) int foo;

as opposed to

__declspec( dllexport ) int foo();

Is there something like a "Read Library Variable" vi?

Thanks,
Cas
0 Kudos
Message 1 of 3
(2,966 Views)
cwierzynski wrote:
> Dear Community,
>
> I am trying to read a variable that is exported by a third-party DLL
> inside a LabView VI. If it were a function, then I would just use a
> "Call Library Function" subvi. But it's not a function; it's a
> variable, something like
>
> __declspec( dllexport ) int foo;
>
> as opposed to
>
> __declspec( dllexport ) int foo();
>
> Is there something like a "Read Library Variable" vi?

Nope! Although possible in Win32 DLLs (Win 3.1 had no standard form for
exported variables at all) it is very seldom used and in fact a bad idea
to do so. Notice that even some normal compilers are not able to
generate the correct export or import mechanisme for them. You could
write a wrapper DLL which exports a read and write function
to those
variables.

I guess with some magic voodoo it would be even possible to generate
some VI code to load the symbol with LoadLibrary and GetProcAddress and
reference the returned pointer as pointer to the variable. Still writing
a wrapper DLL is more secure and IMO the proper way to go.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 2 of 3
(2,966 Views)
thanks for the quick answer, even though it's not what I wanted to hear! C
0 Kudos
Message 3 of 3
(2,966 Views)