To improve the running speed of LabVIEW, the original graphical program is replaced by the DLL call method. I have been calling evc dll these days, but it is a very simple task, but it took several days to get it out. Now I will share it with you.
First, because DLL is nested in the LabVIEW touch panel, labview8.5.1 is used, and the DLL can only be generated using EVC (if labview2009 touch is used, you can use the vc dll directly. I have tried it .) Fundtypes. H, extcode. H, and platdefines. h under national instruments/LabVIEW 8.5/cintools are also required. Therefore, the cintools folder must be written to "Additional include directories ".
Secondly, the build project is the regular DLL Project Test Based on MFC. According to the wizard, after the project is created, you need to add the DLL output function definition in the test. h header file. The Code is as follows:
// If test_exports is defined, set test_api to export; otherwise, set it to import.
# Ifdef test_exports
# Define test_api _ declspec (dllexport)
# Else
# Define test_api _ declspec (dllimport)
# Endif
Note that my program also needs to use the files mentioned above, so note # include "extcode. H"
Next, write the program in test. in the CPP file, it is worth mentioning that all functions output from the DLL should start with the following statement: afx_manage_state (afxgetstaticmodulestate ();, which is used to correctly switch the status of the MFC module. The function name should also be noted.
Long test_api setcallbackprocaddr (long lprocaddress) // note the test_api
{
Afx_manage_state (afxgetstaticmodulestate ());
..................
}
Finally, write the output function of the dynamic link library. The format is as follows: extern "C" Long test_api setcallbackprocaddr (long); if there are many exported functions, you can write them as follows:
Extern "C" // C must be in upper case. If it is in lower case, you may need to begin it. Do not be like me!
{
Long test_api setcallbackprocaddr (long );
...........
}
In addition, set project settings to switch to the C/C ++ tab, and enter test_exports In The Preprocessor definitions edit box to let the compiler pre-define test_exports.
At this point, if there are not too many problems, you can.
But for programmers who use LabVIEW like me, this is not easy. The problem encountered during the compilation at the beginning was that my CPU was not macro-defined, but the problem was found in extcode. h file, because I used labview7.0, which contains extcode. extcode for versions H and 8.5.1. H is different. The difference lies in the definition of arm in version 8.5.1, which makes me spend a lot of time.
Secondly, the compilation process is really long for me now. Every compilation may encounter problems. However, when the problem is solved, it is as sweet as eating honey. During compilation, you need to start from compiling a relatively independent function. This makes it easier to check whether your code is correct or wrong, and it is much easier to change the timing.
The above is my summary of this project. Now it seems that LabVIEW is not enough, and VC ++ is still needed, so it is much easier to get started with EVC. From now on, expand your knowledge and enhance your continuity!
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/paperhappy/archive/2010/01/21/5217199.aspx