error C2371: “IDispatchEx”: 重定义;不同的基类型

发布于 2020-05-05  55 次阅读


问题描述:

用VS2010编译Duilib Demo时报错:

1>  UIWebBrowser.cpp

1>c:program files (x86)microsoft sdkswindowsv7.0aincludedispex.h(217): error C2371: “IDispatchEx”: 重定义;不同的基类型

1>          c:program files (x86)microsoft sdkswindowsv7.0aincludedispex.h(53) : 参见“IDispatchEx”的声明

1>c:program files (x86)microsoft sdkswindowsv7.0aincludedispex.h(435): error C2872: “IDispatchEx”: 不明确的符号

1>          可能是“c:program files (x86)microsoft sdkswindowsv7.0aincludedispex.h(217) : IDispatchEx”

1>          或       “f:duilibduilibbuilddebugflash11.tlh(297) : ShockwaveFlashObjects::IDispatchEx”

1>c:program files (x86)microsoft sdkswindowsv7.0aincludedispex.h(869): error C2872: “IDispatchEx”: 不明确的符号

1>          可能是“c:program files (x86)microsoft sdkswindowsv7.0aincludedispex.h(217) : IDispatchEx”

1>          或       “f:duilibduilibbuilddebugflash11.tlh(297) : ShockwaveFlashObjects::IDispatchEx”

1>c:program files (x86)microsoft sdkswindowsv7.0aincludedispex.h(887): error C2872: “IDispatchEx”: 不明确的符号

1>          可能是“c:program files (x86)microsoft sdkswindowsv7.0aincludedispex.h(217) : IDispatchEx”

1>          或       “f:duilibduilibbuilddebugflash11.tlh(297) : ShockwaveFlashObjects::IDispatchEx”

1>C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludemshtml.h(4715): error C2872: “IDispatchEx”: 不明确的符号

1>          可能是“c:program files (x86)microsoft sdkswindowsv7.0aincludedispex.h(217) : IDispatchEx”

1>          或       “f:duilibduilibbuilddebugflash11.tlh(297) : ShockwaveFlashObjects::IDispatchEx”

1>C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludemshtml.h(4738): error C2872: “IDispatchEx”: 不明确的符号

1>          可能是“c:program files (x86)microsoft sdkswindowsv7.0aincludedispex.h(217) : IDispatchEx”

1>          或       “f:duilibduilibbuilddebugflash11.tlh(297) : ShockwaveFlashObjects::IDispatchEx”


解决方法:

DuiLibControlUIFlash.h 中将下行

#import “..Utils/Flash11.tlb” raw_interfaces_only, named_guids  

改为:

#if _MSC_VER<=1500     //vs2008  

   #import “..Utils/Flash11.tlb” raw_interfaces_only, named_guids  

#elif _MSC_VER<=1600   //vs2010  

   #import “PROGID:ShockwaveFlash.ShockwaveFlash”    

       raw_interfaces_only,       /* Don’t add raw_ to method names */  

       named_guids,           /* Named guids and declspecs */      

       rename(“IDispatchEx”,”IMyDispatchEx”)/* fix conflicting with IDispatchEx ant dispex.h */    

#else                  //vs2013  

   #import “PROGID:ShockwaveFlash.ShockwaveFlash”    

       raw_interfaces_only,       /* Don’t add raw_ to method names */  

       named_guids,           /* Named guids and declspecs */      

       rename(“IDispatchEx”, “IMyDispatchEx”)/* fix conflicting with IDispatchEx ant dispex.h */  

       rename(“ICanHandleException”, “IMyICanHandleException”)  

#endif  


一沙一世界,一花一天堂。君掌盛无边,刹那成永恒。