Using NI-VISA - C

NI-VISA Measurement & Automation

Using NI-VISA (in C)

NI-VISA supports the following C compilers under Windows: LabWindows/CVI, Microsoft Visual C++, and Borland C++. Reference the appropriate examples for each compiler. The examples are in the vxipnp\win95\NIvisa\examples or vxipnp\winNT\NIvisa\examples\ directory. The basic flow of a NI-VISA program is the same under any compiler.

The first function you should call is viOpenDefaultRM(). This initializes NI-VISA and gives you a handle to the VISA Resource Manager that you need in later functions calls. To access an instrument, you obtain a handle to it using viOpen(). You then can set up any asynchronous event handlers that your program may need, then perform your accesses to all your instruments. When you are done, you should call viClose() on each instrument handle and the Resource Manager handle. Be sure to #include visa.h so that all your NI-VISA functions are declared.

Unless you are using LabWindows/CVI, you need to link in the compiler-specific import library visa32.lib. LabWindows/CVI takes care of this step.

See also Communicate with message-based devices in NI-VISA or the NI-VXI API.