06-28-2012 01:56 AM
The Document show that DAQmx do not support on Labwindows less than 7.0. Is there solution that I can use library and functions of DAQmx in LabWindow 6.0 development?
06-28-2012 12:20 PM
Hi Vincent,
You should be able to access the DAQmx C API with unsupported compilers by using LoadLibrary("nicaiu") and GetProcAddress(). It's less convenient than using a supported version of LabWindows/CVI, but it should be possible to get it to work.
Brad
06-28-2012 10:12 PM
Brad,
Your suggestion might help, but I'm not good at Windows SDK. Do you have precise steps or examples for me to include DAQmx API into my application for LabWindow 6.0.
BG,
Vincent Lee
06-29-2012 06:00 PM - edited 06-29-2012 06:05 PM
Hi Vincent,
The best solution would be to upgrade to a supported version of LabWindows/CVI. Version 6.0 is over ten years old.
If you absolutely must take the unsupported route, the basic idea is to call GetProcAddress for each function you want to use, and cast the resulting function pointers to the correct types:
#include <NIDAQmx.h>
#include <windows.h>
int main() {
HMODULE daqmx = LoadLibraryA("nicaiu");
if(daqmx) {
typedef int32 (__CFUNC *DAQmxCreateTaskFnPtr)(const char[], TaskHandle*);
DAQmxCreateTaskFnPtr daqmxCreateTaskFn = (DAQmxCreateTaskFnPtr) GetProcAddress(daqmx, "DAQmxCreateTask");
typedef int32 (__CFUNC *DAQmxClearTaskFnPtr)(TaskHandle);
DAQmxClearTaskFnPtr daqmxClearTaskFn = (DAQmxClearTaskFnPtr) GetProcAddress(daqmx, "DAQmxClearTask");
if(daqmxCreateTaskFn && daqmxClearTaskFn) {
TaskHandle task;
daqmxCreateTaskFn("", &task);
daqmxClearTaskFn(task);
}
FreeLibrary(daqmx);
}
}
This uses NIDAQmx.h for the type and constant definitions, but not the function declarations. Add the corresponding directory (e.g. "C:\Program Files (x86)\National Instruments\Shared\ExternalCompilerSupport\C\include") to the include path.
Note: I tried this code with Visual C++ 2010 but not with LabWindows/CVI 6.0. There may be other incompatibilities between LabWindows/CVI 6.0 and DAQmx that I am not aware of. After all, this combination is unsupported.
Brad
07-01-2012 11:12 PM
Brad,
I have to do it in LabWindows 6.0. Thanks for your information. It really help me a lot.
Vincent Lee