LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Call Library Function in DLL

I write a simple DLL with one function sayhello exported.
__declspec (dllexport) void SayHello(char* info, char* str)
{
strcpy(info,str);
}

Then use the CLF to call the function, when the result is correct. The str can be copied to the info in LabVIEW, but LabVIEW crashed when I close the LabVIEW.

My OS is WindowsXP + SP2, LabVIEW6i.

But I run the demo in LabVIEW7.1 all the things seem correct.

Is this is a bug of LabVIEW6i? I must write my project in LabVIEW6i. Waiting for your help, 3ks!
0 Kudos
Message 1 of 2
(2,489 Views)


@friden wrote:
I write a simple DLL with one function sayhello exported.
__declspec (dllexport) void SayHello(char* info, char* str)
{
strcpy(info,str);
}

Then use the CLF to call the function, when the result is correct. The str can be copied to the info in LabVIEW, but LabVIEW crashed when I close the LabVIEW.

My OS is WindowsXP + SP2, LabVIEW6i.

But I run the demo in LabVIEW7.1 all the things seem correct.

Is this is a bug of LabVIEW6i? I must write my project in LabVIEW6i. Waiting for your help, 3ks!




You need to provide enough storage to the CLF for the DLL function to write the data into. This is standard C programming practice.

So initialize a string at least 1 character longer than the longest expected returned string. A simple way to do that is to use the Initialize Array function to create an array of U8 numbers and using the Numeric Array to String function convert this into a string which you wire to the left terminal for the info parameter.

Rolf Kalbermatter
Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 2 of 2
(2,476 Views)