这一段时间要用到dll中使用ado,在mfc中用ado一段时间没有出现什么问题,本以为在dll中也不会出现什么问题,但是问题产生了,而且是在最开始的导入ado的dll文件时候。我的做法是:
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF") 出现: Compiling resources... Compiling... StdAfx.cpp F:\source\vc\Query\debug\msado15.tlh(169) : error C2011: ''''LockTypeEnum'''' : ''''enum'''' type redefinition F:\source\vc\Query\debug\msado15.tlh(212) : error C2011: ''''DataTypeEnum'''' : ''''enum'''' type redefinition F:\source\vc\Query\debug\msado15.tlh(256) : error C2011: ''''FieldAttributeEnum'''' : ''''enum'''' type redefinition F:\source\vc\Query\debug\msado15.tlh(277) : error C2011: ''''EditModeEnum'''' : ''''enum'''' type redefinition F:\source\vc\Query\debug\msado15.tlh(285) : error C2011: ''''RecordStatusEnum'''' : ''''enum'''' type redefinition F:\source\vc\Query\debug\msado15.tlh(405) : warning C4146: unary minus operator applied to unsigned type, result still unsigned F:\source\vc\Query\debug\msado15.tlh(527) : error C2011: ''''ParameterDirectionEnum'''' : ''''enum'''' type redefinition Error executing cl.exe.
ADIDllTest.dll - 6 error(s), 1 warning(s)
后来经过在csdn上的搜索发现有下面两种办法来解决这个问题
1)
#pragma warning(disable:4146) #import "C:\Program Files\Common Files\System\ADO\msado15.dll" named_guids rename("EOF","adoEOF"), rename("BOF","adoBOF") #pragma warning(default:4146) using namespace ADODB;
2)
#pragma warning(disable:4146) #import "C:\Program Files\Common Files\System\ado\msado15.dll" \ no_namespace \ rename("EOF","adoEOF") rename("DataTypeEnum","adoDataTypeEnum") \ rename("FieldAttributeEnum", "adoFielAttributeEnum") rename("EditModeEnum", "adoEditModeEnum") \ rename("LockTypeEnum", "adoLockTypeEnum") rename("RecordStatusEnum", "adoRecordStatusEnum") \ rename("ParameterDirectionEnum", "adoParameterDirectionEnum")
相对来说,还是第一种方法显得更加简便。
希望以后遇到类似问题的朋友可以给你们一些帮助
[系统软件]用RegDllView揪出所有已注册的dll/ocx [系统软件]Windows系统的活动大陆基石 细看DLL文件 [系统软件]Windows的活动大陆:细看DLL文件 [常用软件]利用msdvm.dll实现微软虚拟桌面 [VB.NET程序]使用VB6.0设计ActiveX DLL事件 [VB.NET程序]Crystal Report(水晶报表)的报表封装成VB的DLL [VB.NET程序]用diskid.dll和disk32.dll获得硬盘序列号 [Delphi程序]输出SHELL32.DLL的图标 [Delphi程序]把图标存储在SHELL32.DLL [Delphi程序]DLL 應用 - 設計可抽換的模組
|