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, and 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 8
(3,536 Views)
Hi friden,


LabVIEW 6i is not "natively" supported on Windows XP because it was released before that OS came out. That could explain why 6i is crashing amd mot 7.1 but that's just a guess...

regards,
Cyril Bouton
Active LabVIEW Developper
0 Kudos
Message 2 of 8
(3,530 Views)
Tks for your answer. I try this demo in Win2K, the problem is still existing. A warnning dialog is showed
dialog title: LabVIEW:labview.exe-Application Error.
information: The instruction at "ox008ad4b6" referenced memory at "0x00646c74". the memory could not be written.

So I think this is not the problem of OS. Do you have any other suggestion?
0 Kudos
Message 3 of 8
(3,505 Views)
Dear Cyril,

The attached file is our dll sourcecode and test vi.
0 Kudos
Message 4 of 8
(3,499 Views)
Hi Friden,

I tried your VI with LabVIEW 6i, 6.1 and 7.1.1 and neither of the versions gave an error or crashed.

Can anyone else replicate the crash?
- Philip Courtois, Thinkbot Solutions

Thinkbot Solutions
0 Kudos
Message 5 of 8
(3,474 Views)
Hi Philips,

You type the string2 with any information which length is bigger than 2. U really can get the correct result. But when you close the test.vi, the LabVIEW will crash. I met this problem in Win2K and WindowsXP.
0 Kudos
Message 6 of 8
(3,453 Views)
friden,

As far as I can tell from your VI and your code, it should be very easy to make your test VI crash LabVIEW: if you enter a longer string in "String 2" than in "String" and then run the VI, LabVIEW is liable to crash because the DLL (in the course of its strcpy) will attempt to overwrite bytes beyond those that have been formally allocated by LabVIEW. LabVIEW may not crash every time in every version on every OS, but it is not an unlikely result.

In other words, it seems to me that your VI and DLL can be expected to work consistently--regardless what LabVIEW version is being used--only if you make sure to enter a large enough string in "String" to accomodate what has been entered in "String 2".

For a great overview of this issue and templates for passing other LabVIEW datatypes to a DLL, check out the Passing a Variety of Data Types from DLL to LabVIEW example. It covers something very similar to what you're doing.

Hope it helps,
John
0 Kudos
Message 7 of 8
(3,446 Views)
Thanks John.

At first I don't want to use the functions in LabVIew.lib, but now I have no choice. Thanks for your help!
0 Kudos
Message 8 of 8
(3,421 Views)