【问题标题】:Imported Type Library no longer working导入的类型库不再工作
【发布时间】:2012-02-09 12:26:25
【问题描述】:

我在 C++ Builder 中有一个大型项目,似乎使用了函数导入类型库。里面有一个像这样标题的文件

// ************************************************************************ //
// WARNING                                                                    
// -------                                                                    
// The types declared in this file were generated from data read from a       
// Type Library. If this type library is explicitly or indirectly (via        
// another type library referring to this type library) re-imported, or the   
// 'Refresh' command of the Type Library Editor activated while editing the   
// Type Library, the contents of this file will be regenerated and all        
// manual modifications will be lost.                                         
// ************************************************************************ //

// C++ TLBWRTR : $Revision:   1.134.1.41  $
// File generated on 2003-10-27 12:57:05 from Type Library described below.

// ************************************************************************ //
// Type Lib: C:\WINNT\system32\MQOA.DLL (1)
// IID\LCID: {D7D6E071-DCCD-11D0-AA4B-0060970DEBAE}\0
// Helpfile: 
// DepndLst: 
//   (1) v2.0 stdole, (C:\WINNT\System32\stdole2.tlb)
//   (2) v4.0 StdVCL, (C:\WINNT\System32\STDVCL40.DLL)
// ************************************************************************ //
#ifndef   __MSMQ_OCX_h__
#define   __MSMQ_OCX_h__

#pragma option push -b -w-inl

#include <utilcls.h>
#if !defined(__UTILCLS_H_VERSION) || (__UTILCLS_H_VERSION < 0x0500)
//
// The code generated by the TLIBIMP utility or the Import|TypeLibrary 
// and Import|ActiveX feature of C++Builder rely on specific versions of
// the header file UTILCLS.H found in the INCLUDE\VCL directory. If an 
// older version of the file is detected, you probably need an update/patch.
//
#error "This file requires a newer version of the header UTILCLS.H" \
       "You need to apply an update/patch to your copy of C++Builder"
#endif
#include <olectl.h>
#include <ocidl.h>
#if !defined(_NO_VCL)
#include <stdvcl.hpp>
#endif  //   _NO_VCL
#include <ocxproxy.h>

...

如您所见,该文件是很久以前生成的 :)。我已经能够在 Windows 7 64 位 上使用 C++ Builder 2010 构建这个项目。但是当我安装 XE2 并尝试修复所有出现的小问题时,因为它现在默认为 STRICT 而不是 NO_STRICT,我遇到了完全不同的问题。上述文件,广告其他以相同方式生成的文件,它们不再按预期工作。

我收到类似

的错误

[BCC32 错误] MSMQ_OCX.h(66):E2090 限定符“Oleserver”不是 类或命名空间名称

寻找它声称没有使用任何类型的 MQOA.DLL 似乎存在。在将项目更新到 XE2 时,是否有人对如何解决此类问题有任何指示?该项目在之前的升级中幸存下来,最后升级到 C++ Builder 2010。但我更喜欢 Visual Studio,所以很多 Embarcadero 的东西都是新领域。

【问题讨论】:

  • 您是否尝试过将 TypeLibrary 重新导入 XE2 而不是重新使用旧的 .h 文件?
  • 我该怎么做?我以为我要查找使用的文件,例如 C:\WINNT\system32\MQOA.DLL 在这种情况下。但此文件在 Windows 7 中不存在。
  • 如果您没有安装该文件,即使您的项目编译正常,您如何期望您的应用在运行时使用 TypeLibrary/Object?
  • 这有点奇怪。由于在 C++ Builder 2010 中,完全相同的代码可以编译和工作,但 dll 仍然不存在。我的观点是 Embarcadero 是一堆巫毒魔法:)
  • 编译不需要DLL。但如果您实际使用的是 TypeLibrary 中定义的 COM 对象,则在运行时确实需要它。

标签: c++builder c++builder-2010 typelib c++builder-xe2


【解决方案1】:

按照 Remy Lebeau 的建议,我最终重新导入所需的类型库并删除了旧的类型库。在我的例子中,它是 Microsoft 的 Message QueuesXML 库。

请注意,给出类似错误消息的其他一些问题可能是编译器只是混淆了:)。尝试在未定义 NO_STRICT 的情况下进行编译。

【讨论】:

  • 如果 c++ 代码(由导入向导生成)仍然无法工作,您还有一个选择 - 将类型库导入 Delphi 包。然后使用选定的项目选项构建和安装包:“生成所有 C++ Builder 文件”。似乎旧版本的 C++ 构建器在使用导入向导生成有效的 C++ 包装类时存在问题。 Pascal 代码生成要好得多 - 无需任何修改即可编译。至少在两个类型库上进行了测试。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-06-01
  • 2016-09-09
  • 1970-01-01
  • 1970-01-01
  • 2010-10-02
  • 1970-01-01
  • 2011-03-21
相关资源
最近更新 更多