|Download Help (Windows Only)|
You can use the #import compiler directive to automatically generate C++ classes for Microsoft Visual Studio to access the objects defined in TestStand type libraries.
To generate C++ classes for TestStand, you must first add the <TestStand>\Bin directory to the list of additional include directories in the Visual C++ project settings.
TestStand adds TestStand API directories to the list of include directories that Microsoft Visual Studio uses to locate files.
In Visual Studio 2010 or later, enable the Enable TestStand Include Directories option on the NI TestStand property page of the Project Properties dialog box for a C++ project to specify whether to use TestStand include directories.
After you update the include directories, add the following directive at the top of the source file:
When compiling this directive, Visual C++ generates teapi.tlh and teapi.tli in a Debug or Release directory that contains the intermediate files for the project. The generated files contain definitions of C++ classes that correspond to the TestStand API classes. Each C++ class contains methods for each of the corresponding TestStand API methods and properties.
By default, Visual C++ encloses the TestStand-generated classes within a TS namespace to avoid possible conflicts with other C++ identifiers that have the same names. As a result, when using the generated classes, you must prefix each class name with TS::, as in TS::Sequence. To avoid the need to prefix the class names with the namespace, you can add the no_namespace attribute to the import directive. You can also add a using namespace TS statement after the import directive, as shown in the following examples:
#import "teapi.dll" no_namespace
using namespace TS;
In addition to teapi.dll, you can import the following files:
The tsapivc.h and tsapivc.cpp files import the type libraries for the TestStand API, TestStand Adapters API, and TestStand UI Controls API.
If you plan to use the TestStand API in many different source files, you might want to add the #import directive to the precompiled header file. Use tsapivc.h and tsapivc.cpp to more easily use the TestStand API in many different files. These files are located in the <TestStand>\API\VC directory. To use these files, include tsapivc.h in the precompiled header and include tsapivc.cpp in a single source file in the project so you can access the TestStand API C++ classes in all of the source files that use the precompiled header.
TestStand does not install MFC wrappers for accessing the TestStand API. If you have source code that uses the tsapimfc.cpp and tsapimfc.h files from a previous version of TestStand, complete one of the following actions when you upgrade TestStand: