Creating an Application with Microsoft Visual C and C++
- 更新时间2025-12-08
- 阅读时长4分钟
This topic assumes that you are using the Microsoft Visual C or C++ ADE to manage your code development and that you are familiar with the following ADEs:
- Microsoft Visual C++ 6.0
- Microsoft Visual Studio 2010
Creating an Application with Microsoft Visual C++ 6.0
To develop an NI-SCOPE application with Microsoft Visual C++ 6.0, follow these general steps:
- Open an existing or new Visual C/C++ project to manage your application code.
- Create source code files of type .c (C) or .cpp (C++).
- Add the source code files to the project.
- Add the following code in the source code files:
#include "niscope.h"
- Add the NI-SCOPE include and library files to the project.
<IVIROOTDIR32> is an alias to a specific National Instruments file folder location. Refer to the NI-SCOPE Readme for more information about installed file locations.
Tip You can modify an NI-SCOPE C example to create an application, and all required include and library files are added to the project for you. [Action: Verify that your driver includes C examples that include Visual C++ project files. If it does not, delete this tip.]
- Select Project»Settings»C/C++»Preprocessor»Additional include directories, and add the paths, separated by a semicolon, to the niscope.h and visa.h files. The niscope.h and visa.h files are located in the <IVIROOTDIR32>\Include and <VXIPNPPATH>\WinNT\Visa\include directories, respectively.
- Select Project»Link»General»Object/Library Modules, and add niscope.lib.
- Select Project»Link»Input»Additional library path, and add the path to the niscope.lib file. The niscope.lib file is located in the <IVIROOTDIR32>\Lib\msc or the <IVIROOTDIR32>\Lib x64\msc directory.
- Build your application using the appropriate programming flow steps.
Creating an Application with Microsoft Visual Studio 2010
To develop an NI-SCOPE application with Microsoft Visual Studio 2010, follow these general steps:
- Open an existing or new Visual C/C++ project to manage your application code.
- Create source code files of type .c (C) or .cpp (C++).
- Add the source code files to the project.
- Add the following code in the source code files:
#include "niscope.h"
- Add the NI-SCOPE include and library files to the project.
<IVIROOTDIR32> is an alias to a specific National Instruments file folder location. Refer to the NI-SCOPE Readme for more information about installed file locations.
Tip You can modify an NI-SCOPE C example to create an application, and all required include and library files are added to the project for you. [Action: Verify that your driver includes C examples that include Visual C++ project files. If it does not, delete this tip.]
- Select Project»Properties»Configuration Properties»C/C++»General»Additional Include Directories, add the paths, separated by a semicolon, to the niscope.h and visa.h files. The niscope.h and visa.h files are located in the <IVIROOTDIR32>\Include and <VXIPNPPATH>\WinNT\Visa\include directories, respectively.
- Select Linker»Input»Additional Dependencies, and add niscope.lib.
- Select Linker»General»Additional Dependencies, and add the path to the niscope.lib file. The niscope.lib file is located in the <IVIROOTDIR32>\Lib\msc or the <IVIROOTDIR32>\Lib x64\msc directory.
- Build your application using the appropriate programming flow steps.
Microsoft Visual C and C++ Examples
Two sets of examples for Visual C/C++ exist. You can find the installed location of these examples in the NI-SCOPE Readme.
- The examples in the first set are C-based console applications that illustrate the NI-SCOPE function calls but have no provision for data display.
- The examples in the second set are C++ examples. They use Microsoft Foundation Classes (MFC) along with Measurement Studio tools for Visual C++. To compile these examples, you need these tools. The source code for these examples is documented, so you can change the code to fit your needs.
Microsoft Visual C Examples
The C examples were built and tested using Microsoft Visual C++ 6.0 with Service Pack 5.0. These examples are console-based with no graphical interface.
To build the examples in Microsoft Visual C++ 6.0 using the Microsoft NMAKE utility, complete the following steps:
- Go to the directory for the particular example you want to use.
- Run the VCVARS32.BAT batch file (located in the \bin directory of the MSVC compiler) to set up the environment variables for command line usage if they are not already set. You might need to increase the initial environment size of the DOS box to accommodate the added environment variables.
- To build an example, run nmake examplename.mak. The executable is built to the debug subdirectory by default.
To build the examples in Microsoft Visual C++ 6.0 using the Microsoft Developer Studio workspace, complete the following steps:
- Go to the directory for the example you want to use.
- Open the project workspace file (.dsw) that launches Developer Studio. You can find the installed location of this file in the NI-SCOPE Readme.
- Add the include directory and lib\msc directories to the project. You can find the installed location of these examples in the NI-SCOPE Readme. To build the examples, the INCLUDE and LIB search paths might need to be modified to find niscope.h and niscope.lib (Tools»Options»Directories or Project»Settings).
- Build the example.