LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to input an array to a DLL

I have been importing DLLs (which I write in C++) into LabVIEW for some time. I have gone through all the DLL examples in LabVIEW 2013, but still can't figure out how to properly import an array whose size is given as an output from the DLL.

 

It seems that (using the Import Shared Library Wizard), I have to specify the array size as a constant value in the import wizard. Then, if I want to change the value, I have to close all my VIs, re-run the entire import wizard, change the number, re-open my VIs and re-run.

 

Is there a better way to do this? I am happy to make any modifications to the DLLs, as required.

 

Many thanks!

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

The Import Library Wizard can't deal with every possible situation under the sun and any variation of user expectation. You should not consider the import library wizard step to be the ultimate step for accessing a DLL, but rather see it as a tool to help you in accessing the DLL. It is a first step that takes a lot of manual and repetitive work out of your hands and then lets you finetune the final VI library to your exact needs. As such it is also not ideal to use for a continously changing DLL as you will basically have to redo the manual finetuning every time after you run the import library wizard.

 

It seems what you want is an extra parameter in the connector pane of your VI that allows you to specify the size of the array that the function should receive to write its data into. If this is the case you can always go and edit te resulting VI library to just do that after the import library wizard has created the VI templates for you. Of course your function you are calling better has a parameter that tells the function how big the array is that it can fill in, otherwise this idea is anyhow doomed. Without such a parameter the only way for the function to know how much data it can fill in is by using a predefined limit that should be documented by the function description and then your buffer you pass in better has at least that size or you end up with memory access violations rather sooner than later.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 5
(2,991 Views)

@rolfk wrote:

The Import Library Wizard can't deal with every possible situation under the sun and any variation of user expectation.


Ah, I actually hadn't realised this. This makes a big difference - thank you for pointing it out.

 


@rolfk wrote:

you can always go and edit the resulting VI library to just do that after the import library wizard has created the VI templates for you.


 

This makes perfect sense. Thank you very much for your help!

 

0 Kudos
Message 3 of 5
(2,971 Views)

I have been trying to do this, but when I modify the auto-generated VI (e.g. to pass in an array size as a control variable), there is no change to the corresponding VI block in my main design.

 

I tried deleting the old block and re-adding it, but still the new controls (inputs) are not there.

 

What am I doing wrong?

0 Kudos
Message 4 of 5
(2,958 Views)

Please upload the VI you have (preferably saved in a previous LabVIEW version "File->Save for Previous Version (2011 or older)") and also post the header file that you use in the import library wizard.

Rolf Kalbermatter
My Blog
0 Kudos
Message 5 of 5
(2,948 Views)