Archived: Can I Make NI-DAQmx Calls From Borland Delphi?This document has been archived and is no longer updated by National Instruments
Primary Software Version: 7.0
Primary Software Fixed Version: N/A
Secondary Software: N/A
Because making NI-DAQmx calls directly from Borland Delphi is not supported I've created a wrapper DLL in Visual C++ that makes NI-DAQmx calls instead. I should be able to call this DLL from Borland Delphi but I receive error -50251 at one of the NI-DAQmx function calls as soon as the DLL is called. However, the same DLL works properly when called from Visual C++. Why is Borland Delphi not able to handle parameters passed from the wrapper DLL that makes calls to the NI-DAQmx driver?
The NI-DAQmx C API type library for Visual Basic 6.0 can be used to create wrapper files that will allow you to use NI-DAQmx in Borland Delphi. This eliminates the need for customers to create their own wrapper files for Delphi.
NOTE: National Instruments does NOT officially support Borland Delphi with NI-DAQmx.
However, even though making DAQmx calls from Borland Delphi is not directly supported, you can create a wrapper DLL to call NI-DAQmx from Delphi. Be aware that you may run into a error -50251 problem unless you mask some exceptions that occur when passing floating point numbers. Apparently, this happens quite frequently when Borland-built applications use components built with non-Borland compilers.
For example, when you try to use OpenGL from Delphi the same type of thing will happen. Most compilers manage floating point error conditions internally under defined rules. However, a number of compilers will always unmask these exceptions in order to enable the compiler's proprietary error handling mechanisms. Borland Delphi by default exposes these errors and certain calls to DAQmx return floating point conversion errors that cause the DLL to crash. To handle these errors one must hide or mask the handful of different error cases that might be encountered. If you fail to mask the exceptions, they make their way to the operating system which will display an error message and then shut down the DLL.
The InitializeFPU procedure below will mask all FPU exceptions, so you should do this before calling any DAQ function.
If your Delphi application requires that FPU exceptions be unmasked, then you can do this immediately after returning from the DAQ function.
KnowledgeBase 38RALVGP: Using Traditional NI-DAQ 7.x with Borland C++...
Boosting the VIA C3's Floating Point Performance
Report Date: 09/09/2004
Last Updated: 06/23/2014
Document ID: 3D8C2TPC