LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

pointer in labview

Hi
 
I developed a dll in labwin and i want to use it in Labview
 
One of the parameter to pass is the address of an HANDLE (void*); so i have to pass **void; void does not exist in labview and so i did the cast of HANDLE to *int in LabWindows;
 
Now i have to pass a **int but this parameter is not an array, because HANDLE is the return type of the function CreateFile ();
 
I chose in labview an array passed by handle **long but the execution of the programm quit suddenly.
 
Any help is welcome
 
Regards. 
0 Kudos
Message 1 of 7
(3,254 Views)
You can't pass **long to **int and expect it to work.  I don't believe there is any way to pass a double pointer to an integer in Labview.  You may have to change the DLL to accept *int or *long.  
Or you could change the DLL to accept **long instead of **int, and then you could use the array passed by handle.  This might work.
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 7
(3,244 Views)

Hi

Thanks for your reply;

I changed the type to **short int and now the types in labview match with the type in Labwindows; the applicationis working in Labwindow with this new type but i have still problem in Labview; the programm crashes. I cannot modify the DLL becasue the function that has the parameter **short int is afunction that i have taken from a library; in this fuction short int **phandle is allocated and initialize with the correct value; to avoid passing short int **, i could read the value of short int * phandle as return type, so that i don't need anymore to pass the pointer to a pointer; int his case i should use a return type in labview a numeric passed by pointer. What do you think?

Please, if you have any suggestion, let me know

Thanks a lot

Giuan

0 Kudos
Message 3 of 7
(3,217 Views)
Hi,
 
I´m not a specialist in passing pointers in LabVIEW from dll´s but perhaps help this link for "debuging" the crashes from LabVIEW.
 
 
Best Regards
Alex
NI Switzerland
Message 4 of 7
(3,197 Views)
Giuan:  As mentioned in the link posted by Alex, check your calling convention.  C or WINAPI.  I have seen that the wrong setting here causes a crash.  I'm not sure which one Labwindows uses, but whichever one you have it set for now, try the other one.
- tbob

Inventor of the WORM Global
Message 5 of 7
(3,187 Views)
Hi all,
 
In C i am using the __stdcall
 
I was using Standard C in labview and so i changed to WINAPI; but now as soon i call the function Labview
 
quit and withoput message error; maybe i do an error when i create the dll in labwindows, i try to explain
 
what i do: i have a file .c with the functions and a file header; i create the dll in labwindow with the option SYMBOL MARKED FOR EXPORT in the box where it is possible to incluede the file.h.
 
Maybe in this procedure there is an error...
 
Any help is welcome
 
Thanks a lot
 
Giovanni
 
0 Kudos
Message 6 of 7
(3,176 Views)
Hi again,
 
I have looked a little bit more on our sites and found an example with this explanation:
 
When you use third-party applications and DLLs, you might want to access memory through data pointers directly in LabVIEW. You can use this utility to do so. The library includes VIs for reading and writing simple numeric data types and C Strings (NULL terminated strings), and includes more general VIs for reading and writing data as flattened data strings. The library also includes functions for allocating and freeing new data buffers on the system heap. Use these functions to access and/or create data buffers for use with external code modules.

Note: These VIs check for NULL pointers, but it still is possible to access illegal or unmapped memory locations and cause access violations or memory faults.
For numeric data, you might need to reverse the byte order before the data can be recognized or used. This is because LabVIEW uses big endian representation while most Windows applications use little endian.
 
Hope this helps!!!
 
Alex
NI Switzerland
Message 7 of 7
(3,146 Views)