LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to call a DLL developed by Delphi in Labview

Hi, everyone

 

I wish to call a dll developed by Delphi, with this function:

ReadInsInfo: function(var StrFac:PChar; var StrSn:PChar; var StrVer:PChar): Integer;

 

However, the three variables in PChar format could not using a conventional C String Pointer calling way.

 

And I have searched and tried the following ways in the forum:

(1) Passing string to PChar data type in a dll created in delphi - NI Community

which suggests using "STR_ASCII-Unicode.vi  lcoated in 'vi.lib\registry\registry.llb' to convert the string to unicode and passing it to the c String", but still failed

(2) How to pass pascal string pointer to Delphi DLL? - NI Community

which suggests using a U8 array, but also failed

 The attachment is the dll (32bit version)

 

Thank you all!

Minwei

0 Kudos
Message 1 of 4
(830 Views)

Why don’t you show what you have done in LabVIEW? Unless Delphi changed something again it should work with those Unicode functions from your first link since Delphi 2010. Before that it would have worked with the explanation in the second link.

 

Please attach VIs not images and backsave them to 2019 or earlier.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 4
(799 Views)

Since there are no pointers in LabVIEW using that obvious setting isn't always, perhaps even never the right choice. I also call DLL functions with pointer arguments and have set  the "Type" to "Adapt to type" and "Data format" to "Handles by value". This at least works for a struct pointer input.

0 Kudos
Message 3 of 4
(774 Views)

@MaSta wrote:

Since there are no pointers in LabVIEW using that obvious setting isn't always, perhaps even never the right choice. I also call DLL functions with pointer arguments and have set  the "Type" to "Adapt to type" and "Data format" to "Handles by value". This at least works for a struct pointer input.


Why don't you show your VI but keep responding with guesses of what might or might not be the correct thing? LabVIEW has indeed no pointers, but the Call Library node lets you configure something that can be used as pointer for a reason. However LabVIEW is a fully managed environment and pointers are fully unmanaged. This means your VI needs to do the managing and you as programmer need to implement that. Yes it is cumbersome and can be complicated, but that's how C interfaces are and a DLL uses the C calling principles and there is nothing NI can do to change that.

 

Adapt to Type can be sometimes the solution but most often isn't, unless you explicitly program the DLL to match the LabVIEW datatype! Since you try to interface to a DLL created by Delphi, which has its own ideas of data types and no trivial way to change them, you can usually assume that Adapt to Type is NOT the right choice.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 4
(764 Views)