LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing a string buffer pointer to a DLL in LabVIEW

Hello there!

I'm trying to call a DLL supplied from hardware manufacturer and all previous calls to the DLL have been of the form:

long hasp(long service, long seed, long lptnum, long pass1, long pass2, long *Par1, long *Par2, long *Par3, long *Par4);

The Call Library Node is using stdcall (WINAPI).

Changing the input parameters Par1 to Par4 have worked well and behaved as described.

One particular function I wish to access requires that a pointer to a string buffer be known and then passed to the DLL. I've tried this function in VB6 and CVI 6.0 under Window 2000 Srv Pck 4 and it works fine but I'm having problems to convert the same VB/CVI code into G. CVI code as follows:

p1 = 0;
/* start address */
p2 = MEMO_BUFFER_SIZE >> 1; /* buffer length in words */
p3 = 0;
p4 = (int)&MemoBuffer;
#endif

/* fill buffer with zeroes to ensure that buffer content */
/* was modified by the READBLOCK service */
memset(&MemoBuffer, 0, sizeof(MemoBuffer));

hasp(MEMOHASP_READBLOCK, SeedCode, PortNum, Pass1, Pass2, &p1, &p2, &p3, &p4)

Input parameter 4 (p4) is the problematic one. I've enclosed the data that is passed to the CVI version of the code as a .jpgs.

I've tried creating a 48 U8 byte buffer (the 48 comes from the CVI .jpg - see &MemoBuffer) using the Initialize Array VI and then type casting it to string and then passing it to the DLL node input. In the Call Library Function, I changed the p4 input to "String" and have tried different "String Formats" but these either make LabVIEW unstable or crash LabVIEW completely.

Can anyone tell me how to pass an unsigned char buffer of 48 chars into the
DLL?

Any help greatly appreciated.

Regards,
Chroma
Download All
0 Kudos
Message 1 of 2
(2,946 Views)
Could you just put the data in a U8 byte array and then pass the data to the dll as:
Parameter: arg1
Type: array
Data type: Unsigned 8-bit Integer
Dimensions: 1
Array Format: Array Data Pointer
This would result in:
unsigned char *arg1

Regards,
Sjoerd
0 Kudos
Message 2 of 2
(2,946 Views)