刚开始看AO方面的书, "地理信息系统开发----ArcObjects方法"上的第一个例子就出了问题.
例子是在一个单文档程序里使用MapControl.
需要导入组件库文件.
书上写的是
#import "c:\Program Files\ArcGis\arcexe83\bin\esriCore.olb" raw_interfaces_only ......
#import "c:\Program Files\Arcgis\arcexe83\bin\MapControl.ocx" raw_interfaces_only ......
我没装ArcGis Desktop, 装的是ArcGIS Engine Runtime 9.2, 用的是VC2005.
于是我改为:
#import "c:\program files\arcgis\com\esriSystem.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids, exclude("OLE_COLOR", "OLE_HANDLE")
#import "c:\program files\arcgis\com\esriSystemUI.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids, exclude("OLE_COLOR", "OLE_HANDLE")
#import "c:\program files\arcgis\com\esriGeometry.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids, exclude("OLE_COLOR", "OLE_HANDLE")
#import "c:\program files\arcgis\com\esriDisplay.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids, exclude("OLE_COLOR", "OLE_HANDLE")
#import "c:\program files\arcgis\com\esriGeoDatabase.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids, exclude("OLE_COLOR", "OLE_HANDLE")
#import "c:\program files\arcgis\com\esriCarto.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids, exclude("OLE_COLOR", "OLE_HANDLE")
#import "c:\program files\arcgis\com\esriControls.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids, exclude("OLE_COLOR", "OLE_HANDLE")
出现了3种错误:
(1) d:\my documents\visual studio 2005\projects\ao\aoex\debug\esrisystemui.tlh(31) : error C3121: cannot change GUID for class 'ICommand'
c:\program files\microsoft visual studio 8\vc\platformsdk\include\oledb.h(6361) : see declaration of 'ICommand'
(2) d:\my documents\visual studio 2005\projects\ao\aoex\debug\esricarto.tlh(1739) : error C2371: 'UINT_PTR' : redefinition; different basic types
c:\program files\microsoft visual studio 8\vc\platformsdk\include\basetsd.h(120) : see declaration of 'UINT_PTR'
重复定义(esricarto.tlh和c:\program files\microsoft visual studio 8\vc\platformsdk\include\basetsd.h里都有个UINT_PTR的定义)
(3) d:\my documents\visual studio 2005\projects\ao\aoex\debug\esrigeodatabase.tlh(17998) : error C2504: 'IRow' : base class undefined
而这个IRow在同一个文件里已经定义了.
------解决方案--------------------
已经解决了.
原来是AO里面的名字和VC自带的些东西名称相同, 在import时重命名一下就行了.
谁来回一下, 我把分给你. 呵呵.