LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems using LabVIEW to call CVI DLL

Hi all!
I have problems to use ddl I create in CVI with LabVIEW. I generate the code with the code generator in CVI. I don't know wich fonction I have to call from LabVIEW. Is it possible to run the dll calling the DllMain (displaying the user interface and waiting for user command)and coming back to LabVIEW application when the user quit the panel?
For the moment, when I select the Dll I want to use in LabVIEW, the user interface appear without running the vi, and LabVIEW scratch!!

Thanks for your help

nico
0 Kudos
Message 1 of 3
(2,766 Views)
You do not call DllMain directly. It gets called automatically.
When you are creating your DLL in CVI, you need to specify which functions you want to export. Exporting a function makes it available to a calling application. The calling application (LabView, in your case) can call only the exported functions. You usually don't export every function in your DLL, only those higher level functions another app will call.
To export functions, create a .h file with the prototypes for functions you want other applications to be able to call. This .h file is not #included in any of your .c or .h files in your DLL project. Add it to your project: from the project window, goto Edit >> Add Files to Project >> Include (*.h), then browse to your .h file. Then, from the project window, goto Build >> Target Settings >> Exports >> Change >> Export What >> Include File symbols, then select the .h file you created for exports, and click OK >> OK.
The prototypes in the .h file for exported functions typically include more details than those in a standard .h file. They will specify the function as extern and will specify the calling convention. For example,
extern int __cdecl MyDLL_Init (int bUseCVIUI);
When I want the option to run the CVI user interface from another language, I'll create a function like MyDLL_Init, and pass it a bolean indicating whether or not I want to use the CVI user interface. For example, in the function declared above, if bUseCVIUI is TRUE, I would load the main panel using LoadPanelEx() and then call RunUserInterface(). In a DLL, call LoadPanelEx(), not LoadPanel(). See the CVI help for these functions. If bUseCVIUI is FALSE, I would do some other init stuff, but not load the panels or run the user interface.
What function you call from LabView (using the Call Library Function Node from the Advanced function palette) depends on what you want to do. In your CVI DLL project, you define the functions you want to call. In LabView, use Call Library Function Node to call them. See the LabView help on Call Library Function Node. Remember that function names are case sensitive.
0 Kudos
Message 2 of 3
(2,766 Views)
Hello
I also want to use a CVI project in Labview. I first thought to use System Exec but it never worked. I have the out of memory message like if INitCVIRTE did'nt work. I tried to use a DLL call like you explain here and it worked but the panel does not close after the QUitUserInterface(0); call. Yet I have a CloseCVIRTE at the end. Is it normal ?
Than you very much
Louis
0 Kudos
Message 3 of 3
(2,766 Views)