OK There are several points to make (that I have learned though this whole process). First of all, building the DLL's for RT are most easily done with using LabWindows/CVI. CVI provides a special option for Run-Time support in the Build Target Settings. With other compilers, the whole build process seems to be very fragile. That recommendation aside, I did manage to get your example to work using VC++ 6.0 (and I am told that it should work for 5.0 as well). On the other hand Visual Studio .Net will NOT work for creating RT DLL's. (this bug is fixed in future LVRT releases)
In VC 6, I created a New project first. I selected Win32 Dynamic Link Library as the project option. The next window asks if you want an empty project or simple DLL project. I selec
ted simple DLL project, and then replaced its generated .cpp file with your DLL source code file. Then I built it, and loaded it with your VI in LabVIEW and it worked fine. As far as changing project options, the preferred Run-Time Execution style is Single Threaded, but it works for any of the other multi-threaded options as well.
I say that its fragile, because I'm still not sure what VC settings caused it to fail several times when I tried creating the project from scratch. But when you go thru the VC steps listed above it worked like a dream. One possible reason for the trouble is that RT DLL's may be extra-sensitive to the passing of pointers; since pointers are not a native data type in LabVIEW.
Another little-known tip for DLL writing, try not to use malloc calls in your DLL's. You can, but it makes things more complicated. You will be much better off declaring your variables in labview and passing them through the left side of the LabVIEW Library Node.
Also,
there's tons of information on DLL writing tips in general located in the LabVIEW help system by searching for the document "Using External Code in LabVIEW".
Darin Gillis
NI - Chief Product Owner - VeriStand