First of all, great sample code. I have no problems running it.
I'm also trying to implement access to a function through a pointer passed to a DLL. The main difference I have is that the function call occurs in my Interrupt Service Routine. A portion of the ISR runs in the DLL, then it jumps out to the function in the DLL user program. After I return to the DLL, it crashes upon exit from the DLL ISR function. I've noticed that the stack only has two functions in it and possibly no link to main; therefore, causing the crash.
Implementation of the ISR is through a lower level function from a licensed driver (PCI) development library. I can't rule out that I'm not implementing the function correctly in the program (Labwindows/CVI). Particularly so because of the comment in cvidll.h from the sample provided:
"Note that we explicitly specify a calling convention for our functions. This is necessary to ensure that caller and callee agree on stack responsibilities. You should always sepcify a calling convention explicitly when prototyping DLL functions."
Since reading the comment, I've added '__stdcall' before all the functions included in my *dll.h. I don't know that I really know which calling convention to use. My main concern is that I attempting to implement this through a DLL for the first time. I have used older versions of this PCI driver library with Visual C++ and LabWindows/CVI version 6.x and had no problems.
Any advise would be greatly appreciated.