LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how pass a string to a vi from a dll?

Solved!
Go to solution

 

 I have a DLL which generates some log errors. How can I display on my front panel those errorlogs? In other words, how to pass a string from a DLL to a vi using the call library funcion?

thank you

 

diego

0 Kudos
Message 1 of 5
(3,109 Views)

Generally you need to allocate the string buffer in LabVIEW. Open up the Example Finder (Help -> Find Examples) and search for DLL. Open the example "Call DLL". It shows you how to call DLLs with various types of arguments.

 

Post back if you have further problems.

Message 2 of 5
(3,099 Views)

what if you don't actually know the size of the strings to be shown in the front panel? they're the error log generated by the dll during execution, I cannot allocate memory in advance because I don't know what string I might get. In this sense, the example seems to be useless. correct me if i'm wrong

thank you

 

diego

0 Kudos
Message 3 of 5
(3,085 Views)
Solution
Accepted by topic author DiegoDC

Is the DLL actually allocating the memory internally for the string? If that's the case, then there should be another function to deallocate the memory. If there isn't you won't be able to do the deallocation from LabVIEW, which means you'd have to write a wrapper DLL. If you don't do the deallocation then you will have a memory leak.

 

Are you sure the DLL isn't simply expecting a buffer "of adequate size"? In this case you can simply create an array of U8 in LabVIEW of a size that's as large as the largest string you expect to get.

0 Kudos
Message 4 of 5
(3,080 Views)

thank you, it was very helpful.

I posted an interesting question I think: how to pass parameter to a dll with call library function while it is executing (for example to command the end of a while loop inside that function from front panel)

see you

 

diego

0 Kudos
Message 5 of 5
(3,059 Views)