LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

passing a string pointer to c dll in labview

I have to access a dll for running an instrument. The dll was written
using c.

Some of the functions I must run from the dll require pointers as
inputs.

For instance, one of the functions requires a pointer to a string
containing the path of a text file on the hard disk containing device
initialisation parameters.

Firstly, I tried writing a second dll that contained 'wrapper'
functions, but LabWindows/CVI wouldn't let me reference a dll from
inside another dll. I've also got Microsoft Visual C++ Express 2005,
but that doesn't seem to have the same functionality as the "Using
External Code in LabView" guide requires.

Will I be OK simply configuring the Call Library Function and setting
the input parameter to 'Type: String' and 'String Format: C String
Pointer' and wiring in a regular labview string to the CLF node? It
won't contain '00'

0 Kudos
Message 1 of 3
(5,144 Views)
Try converting the Labview string into a byte array using String to Byte Array function.  Append 00 at end of byte array so that C will know the end of the string.  Wire the byte array into the Call Library node.  I believe that when wiring an array into a CLN, the address of the first element is actually passed, which is the same as passing a pointer.  In C, a char type is actually the same as a byte, I believe.  A string is an array of characters, or array of bytes, same as Labview U8.  Someone correct me if I'm wrong.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 3
(5,135 Views)
FYI, the Using External Code in LabVIEW document is no longer being revised. As of LabVIEW 8.0, you can find that content in the LabVIEW Help by navigating to the Fundamentals»Calling Code Written in Text-Based Programming Languages book in the Contents tab. The same content is also available at ni.com.
Kelly H
LabVIEW Documentation
National Instruments
0 Kudos
Message 3 of 3
(5,116 Views)