Programming NI-DAQ in Visual C++ 6.0
Primary Software: Measurement Studio>>Visual C++ Support
Primary Software Version: 7.0
Primary Software Fixed Version: N/A
Secondary Software: N/A
Hardware: Multifunction DAQ (MIO)
Problem: What options do I have when programming NI-DAQ in Visual C++ 6.0?
Solution: Refer to the following table when using Visual C++ 6.0 and the DAQ driver (Traditional or DAQmx ) to determine if you can create a NI-DAQ application, whether you have Measurement Studio or not. You can follow the links on the table itself or use the links at the bottom of the page for more information about options with other languages and environments.
- Measurement Studio For Visual Studio.NET provides native .NET Framework 1.1 and MFC C++ libraries for advanced analysis, scientific user interface controls and measurement data networking. Measurement Studio For Visual Studio.NET also provides code generation and integration tools, all for use with Microsoft Visual Studio 2003. Refer to this column if you are developing a DAQ application using Visual Studio .NET 2003 and you have Measurement Studio 7.0 or later.
- Measurement Studio Support for Visual Studio 6.0 provides Visual Basic 6.0 ActiveX controls, MFC Visual C++ libraries for advanced analysis, scientific user interface controls, and measurement data networking. It also provides integration tools for use with Visual C++ 6.0 and Visual Basic 6.0. This support is available as a part of Measurement Studio 7.0 ( Professional package or higher ). Refer to this column if you are developing a NI-DAQ application using Visual Basic 6.0 or Visual C++ 6.0 and you have Measurement Studio Support for Visual Studio 6.0 installed. This was previously available as Measurement Studio 6.0.
- Visual Studio only (without Measurement Studio) refers to the development options if you have only Visual Studio and no Measurement Studio packages. This means you use Visual Studio 6.0 for developing DAQ applications with Visual C++ 6.0.
| |
Measurement Studio For Visual Studio.NET |
Measurement Studio Support for Visual Studio 6.0 |
Visual Studio only (without Measurement Studio) |
| Visual C++ 6.0 |
Traditional NI-DAQ |
N/A |
Yes |
Yes |
| NI-DAQmx |
N/A |
Yes |
Yes |
OPTIMAL: Project wizards, code generation, and configuration tools are provided to accelerate DAQ application development. YES: Native components are provided for this purpose and shipping examples are included. NO: The component is not designed for this environment and its use in that environment is not supported by National Instruments. Click on the link for more information. POSSIBLE: The component was not designed to work natively in that environment, but it is possible to use these components in the required environment by using wrappers or manual configuration. For example, you can use Runtime Callable Wrappers for accessing ActiveX controls in C# or Visual Basic .NET., or by manually setting up a Visual C++ project to use C import libraries. Refer to the link for more information. N/A: The particular Measurement Studio package does not provide support for the particular language. Refer to the link for more information. |
Visual C++ 6.0 with Measurement Studio Support for Visual Studio 6.0
- Traditional NI-DAQ
- National Instruments does not include native C++ class libraries for Traditional NI-DAQ.
- Use the ANSI C API that is available by installing the Traditional NI-DAQ driver. This does not require Measurement Studio.
- You can find the examples in the following default directory location :
C:\Program Files\National Instruments\NI-DAQ\Examples\VisualC. You can view these examples after installing the Traditional NI-DAQ driver.
- You can use the Traditional NI-DAQ ActiveX controls to perform data acquisition. The ActiveX controls are provided with the Traditional NI-DAQ driver and do not require Measurement Studio. The CWDAQ control is installed as a part of the Traditional DAQ driver.
- Example programs for Visual C++ with CWDAQ can be found at the following location:
ftp://ftp.ni.com/support/compworks/samples/
- NI-DAQmx
Note: These examples are the same examples referred to in the Visual C++ 6.0 without Measurement Studio section for more information.
You can find examples in the following default directory location: C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C.These examples were created using Visual C++ 6.0, and are available by installing the NI-DAQmx driver. Measurement Studio is not required.
To manually add the NI-DAQmx libraries to a Visual C++ 6.0 project, complete the following steps:
- SelectTools»Options»Projects »Directories. From the pulldown menu on the right side, you can select different directories to look in for include and library files.
- Add the following path for include files:
C:\Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\include
- Add the following path for the library file:
C:\Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\lib\msvc.
- Note: These examples are the same examples referred to in the Visual C++ 6.0 without Measurement Studio section, but in this section you can add the Measurement Studio ActiveX controls for a graph, slider, etc., to the examples.
Visual C++ 6.0 with Measurement Studio for Visual Studio .NET
- Traditional NI-DAQ
- Measurement Studio Support for Visual Studio .NET will not provide you any additional functionality for developing Traditional NI-DAQ applications using Visual C++ 6.0.
- Measurement Studio for Visual Studio .NET Professional package or higher includes a separate CD that installs support for Visual Studio 6.0. This provides project wizards, data networking, Analysis C++ class libraries, and ActiveX user interface controls you can use from Visual C++ 6.0. If you have Measurement Studio for Visual Studio .NET Professional package or higher, refer
to the Visual C++ 6.0 with Measurement Studio Support for Visual Studio 6.0section .
- NI-DAQmx
Visual C++ 6.0 with Measurement Studio Support for Visual Studio 6.0section .
- NI-DAQmx
Visual C++ 6.0 without Measurement Studio
- Traditional NI-DAQ
- National Instruments does not include native Visual C++ class libraries for Traditional NI-DAQ.
- You can find examples at the following default directory:
C:\Program Files\National Instruments\NI-DAQ\Examples\VisualC. These examples are provided examples for Visual C++ 6.0 without Measurement Studio. To compile and run the examples, follow these instructions:
- Open Microsoft Visual C++.
- Select File»Open.
- Navigate to the following path:
C:\Program Files\National Instruments\NI-DAQ\Examples\VisualC.
- Open the specific
.c file you are interested in running. The .c file will open in the window, but it will not be inside a project.
- Select Build»Rebuild All.
- Select Yes in the popup window that asks you if you would like to build a default workspace. A default workspace will open.
- Add the specific
.c file to the project. The .c file will automatically compile, but you will probably have a few linking errors. This is because the .lib files have not been added to the project.
- Switch to the File View from the Class View.
- Right-click on Project name files, and select Add files to project.
- Navigate to the following path:
C:\Program Files\National Instruments\NI-DAQ\Lib.
- Select All Files for the Files of Type field.
- Select both
nidaq32.lib and nidex32.lib.
- After adding these
.lib files to the project, select Build»Rebuild All. The project should compile without any compile or linking errors. Execute the program and view the results.
- If you still encounter errors,
- Select Tools>>Options from the menu, then click on the "Directories" tab. You will find a list box labeled "Show directories for:" . First select "include files" and enter the directory to your include (.h) files. The default installation path is shown below.
C:\Program Files\National Instruments\NI-DAQ\include
(Hint: If you want to browse for your files, simply double click in the space below the last file path in the list. This will highlight the area and show an ellipsis at the right-hand side. Click on the ellipsis and navigate to your file.>
- Next select "library files" in the "Show directories for:" list box and add the path to the library file. The default installation path is shown below.
C:\Program Files\National Instruments\NI-DAQ\lib\
Click OK after adding the file paths.
- Build»Rebuild All. The project should compile without any compile or linking errors. Execute the program and view the results.
- You can use the Traditional NI-DAQ ActiveX controls to perform data acquisition. The CWDAQ ActiveX control is provided with the Traditional NI-DAQ driver and does not require Measurement Studio.
- You can find more example programs for Visual C++ with CWDAQ at the following location:
ftp://ftp.ni.com/support/compworks/samples/.
- NI-DAQmx
- You can find examples at the following default directory location:
C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C. Open and run these examples with the following steps:
- Open Visual C++.
- Select File»Open.
- Navigate to the following path:
C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C.
- Select which type of example you want to run and double-click the workspace.
- The first time you run these examples, you will need to add the DAQmx include and library files to the Visual Studio environment. Select Tools»Options.
- Click the Directories tab. Make sure you are viewing the directories for include files, and add the following new path:
C:\Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\include.
- Add a link for library files with the following path:
C:\Program Files\National Instruments\NI-DAQ\DAQmx ANSI C Dev\lib\msvc.
Related Links: KnowledgeBase 317742FQ: Programming NI-DAQ in Text-Based Languages
KnowledgeBase 3146J6FQ: Programming DAQ in Visual Basic 6.0
KnowledgeBase 3178NEFQ: Programming DAQ in Visual Basic .NET
KnowledgeBase 317CP7W3: Programming DAQ in Visual C++ .NET
KnowledgeBase 3186P9W3: Programming DAQ in Visual C# .NET
Attachments:
Report Date: 09/08/2003
Last Updated: 10/12/2006
Document ID: 317BPGW3