LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with Delphi 6 and DLL created in LV6.1

Dear all,

This is my problem:

I need to integrate a DLL named test.dll and created in LV 6.1 into a Delphi v.6 program.


This DLL contains a function declared as this:

int32 __cdecl test(int32 CodeProduct, char DataRead[], int32 DataLength);

The parameters are these ones:

- CodeProduct: 32-bit integer.
- DataRead: C String Pointer with DataLength bytes. Returns the read alphanumeric string.
- DataLength: Length of DataRead. 32-bit integer.

- Function returns an error code (32-bit integer). It is declared as cdecl (C Convention Call).

In Delphi 6 the function is declared as follows:

function test(CodeProduct : Integer;var DataRead : Pchar;DataLength : Integer):Integer;cdecl;external 'test.d
ll' name 'test';

The function loads well into the Delphi Program, but when it is called, the program hangs up. Debug is not possible, because it looks that the problem lies in the conversion of Delphi type PChar to LabView type Cstring. There is not any problem with the integer type. He have tried with Pascal strings, array of bytes, array of char, stdcall or cdecl, but it does not work.

Any ideas?

The dll is attached to this message.

Thanks.
0 Kudos
Message 1 of 2
(2,789 Views)
Hello Miguel,

I think you are right in that the issue has been boiled down to the differences between the Delphi and LabVIEW string data types. Even though you are using a LabVIEW dll in Delphi, I would recommend looking over the External Code manual for LabVIEW, which can be found at the following site:

http://digital.ni.com/manuals.nsf/webAdvsearch/8D930295FFBF9F7686256D2C00624728?OpenDocument&vid=niwc&node=132100_US

I would focus specifically on information about passing LabVIEW string information.

Otherwise, it sounds as if you are doing everything correctly. Have you tried using the LV DLL in anything other than Delphi?

I hope this helps! Let me know how it goes.

Liz Fausak
0 Kudos
Message 2 of 2
(2,789 Views)