Using NI-HSDIO in Visual C++
This topic assumes that you are using the Microsoft Visual C++ ADE to manage your code development and that you are familiar with the ADE.
To develop an NI-HSDIO application in Visual C++, follow these general steps:
- Open an existing or new Visual C++ project.
- Create source files of type .c (C source code) or .cpp (C++ source code) and add them to the project. Make sure that you include the NI-HSDIO header file, niHSDIO.h, as follows in your source code files: #include "niHSDIO.h"
- Specify the directory that contains the NI-HSDIO header file under the Preprocessor»Additional include directories settings in your compiler—for Visual C++ 6.0 these files are under Project»Settings»C/C++. The NI-HSDIO header files are located in the .\Include directory within your NI-HSDIO directory.
- Add the NI-HSDIO import library niHSDIO.lib to the project under Link»General»Object/Library Modules. The NI-HSDIO import library files are located in the .\Lib directory within your NI-HSDIO directory.
- Add NI-HSDIO function calls to your application.
- Build your application.
Example Programs for Visual C++
You can find example programs at the location specified in the NI-HSDIO Instrument Driver Readme or from the Start menu by selecting Programs»National Instruments»NI-HSDIO»Examples»c.
All C examples are installed with support makefiles that are executable from a command prompt. To build examples, run vcvars32 to set up your build environment. From the example directory, type nmake /f makefilename.
Note You might get a compiler error if the example uses NI-HWS because some operating systems may not be able to resolve the $(PROGRAMFILES) variable referred to in the makefile. Replace HWSPATH=$(PROGRAMFILES)\National Instruments\NI-HWS in the makefile with the absolute install path for NI-HWS. The default absolute path is specified in the NI-HSDIO Instrument Driver Readme. |
Special Considerations
String Passing
To pass strings, pass a pointer to the first element of the character array. Be sure that the string is null-terminated.
Parameter Passing
By default, C passes parameters by value. Remember to pass pointers to variables when you need to pass by address.