请问各位专家,如何将一个mydll文件静态链接到应用程序myapp中,即应用程序myapp在没有安装mydll的机器上正常运行。只要能做到脱离mydll而运行myapp,采用任何方法都可,非常感谢!

解决方案 »

  1.   

    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”)
      

  2.   

    可以吗,完全不可能。楼上说的#import指定引入声明,并不引入实现。而且import是用于引入com的tlb库的。