LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling VC++ dll functions from CVI 7.1.1

I'm trying to develop a program for some hardware, which  has a supplied dll written in MS Visual C++. I have read the FAQ at
http://zone.ni.com/devzone/conceptd.nsf/webmain/1D0C73348D50DE5486256FAF00614757
 - in particular the last section which describes how the C++ export functions must be declared with extern "C" for proper linking. I scanned the suppplied dll with Dependency Walker as described on the page, and the function names are correct and listed as C (not C++).

I can get my program to compile, but as soon as I call any of the export dll functions, the program crashes with a fatal run-time error - "priviledged instruction" fault. All of the functions use some port I/O, ie inp and outp instructions.

I used the supplied .h file to create the .lib dll import library, but I can't specify the extern "C" in the .h function definitions (syntax errors - I guess CVI doesn't like "" in definitions).

Any thoughts would be appreciated!



0 Kudos
Message 1 of 3
(3,251 Views)

Hello Zog,

Since you mentioned you are using low level driver functions such as inp, in order to make sure your calls to these functions can execute correctly, call CVILowLevelSupportDriverLoaded at the beginning of your CVI program.  Also, make sure you save the lib and h files in your project folder and include them in your workspace.

Let me know if this helps the problem.

Wendy L
LabWindows/CVI Developer Newsletter
0 Kudos
Message 2 of 3
(3,236 Views)
Thanks for trying to help Wendy, but I have already tried all of the above.

Contacting the vendor of the hardware/dll didn't help either.
0 Kudos
Message 3 of 3
(3,232 Views)