The #import Directive C++ Specific The #import directive is used to incorporate information from a type library. The content of the type library is converted into C++ classes, mostly describing the COM interfaces.Syntax#import "filename" [attributes]#import <filename> [attributes]attributes:attribute1, attribute2, ...attribute1 attribute2 ...filename is the name of the file containing the type library information. A file can be one of the following types: a type library (.TLB or .ODL) file an executable (.EXE) file a library (.DLL) file containing a type library resource (such as .OCX) a compound document holding a type library any other file format that can be understood by the LoadTypeLib API The filename is optionally preceded by a directory specification. The filename must name an existing file. The difference between the two forms is the order in which the preprocessor searches for the type library files when the path is incompletely specified.Syntax Form Action Quoted form This form instructs the preprocessor to first look for type library files in the same directory of the file that contains the #import statement, and then in the directories of whatever files that include (#include) that file. The preprocessor then searches along the paths shown below. Angle-bracket form This form instructs the preprocessor to search for type library files along the paths shown below. The compiler will search in the following directories for the named file: the PATH environment variable path list the LIB environment variable path list the path specified by the /I (additional include directories) compiler option #import can optionally include one or more attributes. These attributes tell the compiler to modify the contents of the type-library headers. A backslash (\) symbol can be used to include additional lines in a single #import statement. For example:#import “test.lib” no_namespace \ rename(“OldName”, “NewName”)
C++ Specific The #import directive is used to incorporate information from a type library. The content of the type library is converted into C++ classes, mostly describing the COM interfaces.Syntax#import "filename" [attributes]#import <filename> [attributes]attributes:attribute1, attribute2, ...attribute1 attribute2 ...filename is the name of the file containing the type library information. A file can be one of the following types: a type library (.TLB or .ODL) file
an executable (.EXE) file
a library (.DLL) file containing a type library resource (such as .OCX)
a compound document holding a type library
any other file format that can be understood by the LoadTypeLib API
The filename is optionally preceded by a directory specification. The filename must name an existing file. The difference between the two forms is the order in which the preprocessor searches for the type library files when the path is incompletely specified.Syntax Form Action
Quoted form This form instructs the preprocessor to first look for type library files in the same directory of the file that contains the #import statement, and then in the directories of whatever files that include (#include) that file. The preprocessor then searches along the paths shown below.
Angle-bracket form This form instructs the preprocessor to search for type library files along the paths shown below.
The compiler will search in the following directories for the named file: the PATH environment variable path list
the LIB environment variable path list
the path specified by the /I (additional include directories) compiler option
#import can optionally include one or more attributes. These attributes tell the compiler to modify the contents of the type-library headers. A backslash (\) symbol can be used to include additional lines in a single #import statement. For example:#import “test.lib” no_namespace \
rename(“OldName”, “NewName”)