From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Archived: Programming Traditional NI-DAQ (Legacy) in Visual C++ (MFC)

NI does not actively maintain this document.

This content provides support for older products and technology, so you may notice outdated links or obsolete information about operating systems or other relevant products.

Overview



This article explains the different options available when programming with NI-DAQmx or Traditional NI-DAQ (Legacy) using Visual C++ (MFC). Environments include Visual Studio 6.0, 2003, 2005 and 2008.

Contents

Introduction

Note: Measurement Studio no longer provides active support for Visual Studio 6.0, Visual Studio 2003, and Visual C++ MFC.  

Refer to this table when using Visual C++.NET and the NI-DAQ Driver (Traditional (Legacy) or DAQmx ) to determine if you can create a NI-DAQ application whether you have Measurement Studio installed 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 the options.

  • Measurement Studio for the Visual Studio 2003/2005/2008 environments provides a collection of managed .NET and MFC C++ libraries* for advanced analysis, scientific user interface controls and measurement data networking. It also provides code generation and integration tools with Visual Studio. Refer to the Measurement Studio for Visual Studio 2003/2005/2008 column if you are developing a NI-DAQ application using Visual Studio 2003/2005/2008 and you have Measurement Studio 7.0 or later.
  • Measurement Studio Support for Visual Studio 6.0 provides ActiveX controls, MFC Visual C++ libraries, and 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 Edition or higher). Refer to this column if you are developing a 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 2003 or higher for developing applications using Visual C++(MFC).

 

DAQ Visual C++ (MFC) Recommended Environments

 

Measurement Studio for Visual Studio 2003/2005/2008

Measurement Studio Support for Visual Studio 6.0

Visual Studio only
(without Measurement Studio)

Traditional NI-DAQ
(Legacy)

Yes*

N/A

Yes

NI-DAQmx

Optimal*

N/A

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.

N/A: The particular Measurement Studio package does not provide support for the particular language. Refer to the link for more information.

* : MFC C++ libraries available for Visual Studio 2005 and 2003 only.

 

Visual C++ (MFC) with Measurement Studio Support for Visual Studio 2003/2005/2008

Traditional NI-DAQ (Legacy)

  • NI-DAQmx replaced Traditional NI-DAQ (Legacy) in 2003. NI strongly recommends using NI-DAQmx for new applications.
  • National Instruments does not provide native .NET or Visual C++ (MFC) libraries for Traditional NI-DAQ. Measurement Studio Support for Visual Studio 2003/2005/2008 will not provide you any additional functionality for developing Traditional NI-DAQ (Legacy) applications in Visual Studio 2003/2005/2008.
  • Use the ANSI C API that is available by installing the Traditional NI-DAQ driver. This does not require Measurement Studio. Refer to the Visual C++ (MFC) without Measurement Studio section for more information.
  • You can use the Traditional NI-DAQ ActiveX controls to perform data acquisition. The ActiveX controls are provided with the Traditional NI-DAQ (Legacy) Driver and do not require Measurement Studio. The CWDAQ control is installed as a part of the Traditional NI-DAQ (Legacy) Driver.

NI-DAQmx

  • National Instruments provides a C API for NI-DAQmx. This is available as a part of the driver and does not require Measurement Studio.
  • Measurement Studio Support for Visual Studio 6.0 will not provide you any additional functionality for developing NI-DAQmx applications in Visual Studio 2003.
  • You can find examples in the following default directory location: <National Instruments>\NI-DAQ\Examples\DAQmx ANSI C. These are examples written using Visual Studio 6.0, but Visual Studio 2003/2005/2008 will automatically update the project to a Visual Studio .NET solution for you. Refer to Visual C++ .NET without Measurement Studio for information on how to manually add the NI-DAQmx headers and libraries to the Visual Studio 2008/2005/.NET 2003 environment.
  • Refer to examples in the Visual C++ .NET without Measurement Studio section for information on how to add NI-DAQmx functions to the examples.

 

Visual C++ (MFC) without Measurement Studio

Traditional NI-DAQ (Legacy)

  • NI-DAQmx replaced Traditional NI-DAQ (Legacy) in 2003. NI strongly recommends using NI-DAQmx for new applications.
  • National Instruments does not provide native .NET components or Visual C++ (MFC) class libraries for Traditional NI-DAQ (Legacy)
  • For this scenario, you can run the examples that are installed with Traditional NI-DAQ (Legacy), that were initially written to be run with Visual C++ 6.0. The examples are found in the following default directory location: <National Instruments>\NI-DAQ\Examples\VisualC. You can run these examples in Visual C++ (MFC) by completing the following steps:
  1. Open Visual Studio.NET
  2. Select File»New»Project
  3. In the project window, select Visual C++ Projects and Win32Project.
  4. Enter a project name. Click OK
  5. Select Application Settings
  6. On the Application Settings, select Console Application and Empty Project. Click Finish. This will create the empty project for you.
  7. In the Solution Explorer box, right-click on the source files, and select Add »Add Existing Item.
  8. Navigate to the example path: <National Instruments>\NI-DAQ\Examples\VisualC, and then into the specific example you want to run.
  9. Select the specific .c file you want to run, and click Open
  10. Add the library files that are needed to run these applications. You can find these libraries at the following location: <National Instruments>\NI-DAQ\Lib. Add these to your project by right-clicking on the source files, and selecting Add»Add Existing Item.
  11. Navigate to the above path. Once you are in the correct folder, you will want to change the files types that you are looking for from C++ file type to All files, then select both library files (nidaq32.lib and nidex32.lib), and click Open. This will add both files to your project and the file should now compile and run.
  12. Run the program by clicking the blue arrow on the toolbar. (If you still have errors, check to make sure the Include and Library paths are correct.
    Note: Check the paths by selecting Tools»Options. Then select Projects»Visual C++ Directories. Select Include files, and make sure that there is a path added to any .h files that your project references. Specifically, be sure that the following path is there: <National Instruments>\NI-DAQ\Include. Make sure that under Library Files, there is the following path to the library files: <National Instruments>\NI-DAQ\Lib.
  • You can also add the Traditional NI-DAQ (Legacy) ActiveX controls to perform data acquisition. The ActiveX controls are provided with the Traditional NI-DAQ (Legacy) Driver and do not require Measurement Studio. The CWDAQ control is installed as a part of the Traditional NI-DAQ (Legacy) Driver.

NI-DAQmx

  • National Instruments provides a C API for NI-DAQmx. This is available as a part of the driver and does not require Measurement Studio.
  • You can find examples in the following default directory location: <National Instruments>\NI-DAQ\Examples\DAQmx ANSI C. These examples are written using Visual C++ 6.0. Visual Studio 2003/2005/2008 will automatically convert the Visual C 6.0 projects to the correct format. To manually add the NI-DAQmx libraries to your projects, select Tools»Options. In the Options dialog box, select Projects»Directories. Select include and library files. For example, you will want to add the following path for include files: National Instruments>\NI-DAQ\DAQmx ANSI C Dev\include, and a path for the following library file: <National Instruments>\NI-DAQ\DAQmx ANSI C Dev\lib\msvc.

Was this information helpful?

Yes

No