boo123 wrote:
> I have a problem with my labview VI and my DLL. I know that the DLL
> works correctly, because I've created a sample exe and called the DLL
> from it and it works as expected. Now I've decided to use labview to
> call the DLL, but it keeps crashing.
>
> This is the function prototype:
>
> _declspec (dllexport) void readFile(char *fileName);
>
> Now, the DLL function is called in my labview VI with these specs:
> Calling convention: C
Maybe you should try to use stdcall if you are on Windows. Just try out
as this is usually one of the reasons why it could crash.
> Parameter: fileName
> Type: Array
Change this to string
> Data Type: Signed 8-bit Integer
> Dim: 1
> Array Format: Array Data Pointer
and string format: C type pointer
> Which gives me: void readFile_(char *fileName)
Which will give you the same line. C declaration is sometimes not very
unambiguous.
> I'm inputting the string like this: String->Decimal String to number
> converter -> readFile
With above configuration you don't need any conversion and LabVIEW makes
sure that the string is properly zero terminated as most C string
fucntions expect.
> Here the program crashes saying that "Labview: An Exception occurrec
> with the external code ... "
This could also be because the DLL function tries to go through the
string until its NULL termination character and since it isn't where it
should be runs over its end and accesses other data.
Rolf Kalbermatter
Rolf Kalbermatter
My Blog 
DEMO, Electronic and Mechanical Support department, room 36.LB00.390