From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I use the dll with the return type is "const void*" in LabVIEW

I’m use LabVIEW with dll,there are some problems whit one funtion of the dll,the dll was been written with c++ and the funtionwas been written liks this :
const void* MSPAPI QTTSAudioGet ( const char * sessionID,
unsigned int * audioLen,
int * synthStatus,
int * errorCode

)

123456.png
I don’t know how to choice the return type with the style of ‘const void*’,can you give me some suggestion?

 

0 Kudos
Message 1 of 8
(3,981 Views)

I'd expect void to work.  It's pretty strange to have a constant pointer to a void.  Void means there's nothing there.  That, by default, is constant.  Why would you ever want a pointer to it?

 

What happens when you leave it as void?  Does it error?  Does it crash?

0 Kudos
Message 2 of 8
(3,956 Views)

The 'const void*' means the the pointer of the return data,and the type of data returned is an array of binary files,I've got the data with 'MoveBlock DLL',but I don't know why 'MoveBlock DLL' always strikes,It may have the other problem of the 'MoveBlock DLL'.

0 Kudos
Message 3 of 8
(3,922 Views)

The return type should be configured as a pointer-sized integer. You can then pass that value to MoveBlock as the source address. Since the value on the wire is already a memory address, you must configure that parameter as passed by value, not by pointer. If you cannot get this working, please attach your LabVIEW code showing how you've configured the Call Library Function Nodes.

 

@natasftw - There is nothing strange about a void * pointer, not even a const void *. In C it's common to use void * the way you use a variant in LabVIEW. It's a generic pointer. The const keyword here indicates that the object pointed to is read-only, but that doesn't mean that it points at void. It can be cast to a pointer to a constant of some other type. I assume this function returns a pointer to some constant object that the DLL allocates once statically.

0 Kudos
Message 4 of 8
(3,912 Views)

Hi,This is my LabVIEW code , I have configured the Call Library Function Nodes as flowed,it worked fallible with the error code 1097,

MoveBlock.png

MoveBlock1.png

MoveBlock2.png

MoveBlock3.png

0 Kudos
Message 5 of 8
(3,894 Views)

There is not enough information in your images to see how you've configured everything. For example, which calling convention did you use for both calls to the DLL? Please upload your VI, preferably saved back to LabVIEW 2015 or earlier, instead of posting images; or at least, post a snippet rather than a simple image.

0 Kudos
Message 6 of 8
(3,881 Views)

I have solved this problem,the  'MoveBlock DLL' itself is no problem, the problem is on another DLL was provied by other person,which return one error pointer sometimes,so  'MoveBlock DLL' get error.

Thanks for all you help.

0 Kudos
Message 7 of 8
(3,860 Views)

Most likely it returns a NULL pointer when something went wrong! That is of course something your code needs to check and make sure to not blindly call MoveBlock() on such a pointer.

Another option is that the function returns the pointer as parameter and also returning an error code. In such cases defensive programming mandates to both check the error code and also the pointer to be non NULL, before proceeding!!

Rolf Kalbermatter
My Blog
0 Kudos
Message 8 of 8
(3,853 Views)