LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

PWideChar in dll call from LabVIEW

Solved!
Go to solution

Here is a simple function:

 

GetPDFPageCount
function:

=====

GetPDFPageCount(const FileName: PWideChar): LongInt; stdcall;

 

I have tried defining the Argument:

 

FileName as string input but the dll was not able to read the filename.

 

Question: how does LabVIEW DEFINE PWideChar input datatype?

 

Anthony

 

0 Kudos
Message 1 of 3
(902 Views)
Solution
Accepted by topic author Anthony_L

@Anthony_L wrote:

 

Question: how does LabVIEW DEFINE PWideChar input datatype?


Simple answer: Not!

 

Complicated answer: You have to do some C compiler work of your own on the LabVIEW diagram. Basically a PWideChar is the Pascal variant of LPWCHAR Windows datatype. So you have to call the Windows API MultiByteToWideChar() to turn the LabVIEW string, which is an 8-bit ASCII string, into a Unicode Widechar array.

 

You can find in this post a library to do the conversion.  I would use the variant that creates an U16 array. It has the advantage that you do not need to deallocate any pointers after use, since the data is a LabVIEW array and managed by LabVIEW directly.

 

Your function parameter then has to be configured to be an Array of UInt16, Passed as C string pointer.

 

 

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 3
(866 Views)

Rolfk:

 

That worked perfectly!!! Thanks!!

 

Here is a picture of the code base

 

Anthony

0 Kudos
Message 3 of 3
(850 Views)