02-11-2009 10:27 AM
I have a Labview program that will call a number DLLs written in C++. I'm trying to setup my DAQ using DAQMX so that when I call the C++ DLLs, they can in turn call the DAQRead functions from DAQMX.
Looking into a simple boolean digital readin DAQMX, it calls the DAQRead1Chan1Samp1LineBool method in nilvaiu.dll - I wrote a C++ DLL to call this instead, but I'm running into problems - see code snippet below. Is anyone able to point out where I'm going wrong?
int mydaq(int taskID, char* value)
{
/* get handle to dll */
HINSTANCE hGetProcIDDLL = LoadLibrary("nilvaiu.dll");
/* get pointer to the function in the dll*/
FARPROC lpfnGetProcessID = GetProcAddress(HMODULE (hGetProcIDDLL),"DAQRead1Chan1Samp1LineBool");
/*
Define the Function in the DLL for reuse. This is just prototyping the dll's function.
A mock of it. Use "stdcall" for maximum compatibility.
*/
typedef int (__cdecl * pICFUNC)(int, long, char*, char*);
pICFUNC DAQRead1Chan1Samp1LineBool;
DAQRead1Chan1Samp1LineBool = pICFUNC(lpfnGetProcessID);
/* The actual call to the function contained in the dll */
int intMyReturnVal = DAQRead1Chan1Samp1LineBool(taskID, 1.0, value, "");
/* Release the Dll */
//FreeLibrary(hGetProcIDDLL);
return true;
}
Cheers,
Dougie
02-11-2009 11:23 AM
Never mind, needed caffeine! Problem solved
int mydaq(unsigned int taskID, unsigned char* value)
{
/* get handle to dll */
HINSTANCE hGetProcIDDLL = LoadLibrary("C:\\WINDOWS\\system32\\nilvaiu.dll");
/* get pointer to the function in the dll*/
FARPROC lpfnGetProcessID = GetProcAddress(HMODULE (hGetProcIDDLL),"DAQRead1Chan1Samp1LineBool");
/*
Define the Function in the DLL for reuse. This is just prototyping the dll's function.
A mock of it. Use "stdcall" for maximum compatibility.
*/
typedef int (__cdecl * pICFUNC)(unsigned int, double, unsigned char*, char*);
pICFUNC DAQRead1Chan1Samp1LineBool;
DAQRead1Chan1Samp1LineBool = pICFUNC(lpfnGetProcessID);
/* The actual call to the function contained in the dll */
int intMyReturnVal = DAQRead1Chan1Samp1LineBool(taskID, 1.0, value, "");
/* Release the Dll */
FreeLibrary(hGetProcIDDLL);
return intMyReturnVal;
}