关闭

vs2010 vc++开发引用 ArcEngine9.3 组件和AO对象实例化方法

标签: vc++2010typeswarningspathheader
3222人阅读 评论(2) 收藏 举报
分类:

vs2010 vc++开发引用 ArcEngine9.3 组件和AO对象实例化方法

//stdafx.h文件最下面添加如下代码

//添加ArcEngine dll引用


#pragma warning(push)
#pragma warning(disable : 4192) /* Ignore warnings for types that are duplicated in win32 header files */
#pragma warning(disable : 4146) /* Ignore warnings for use of minus on unsigned types */
 
#import "D:/Program Files/ArcGIS/com/esriSystem.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids, exclude("OLE_COLOR", "OLE_HANDLE", "VARTYPE")
#import "D:/Program Files/ArcGIS/com/esriSystemUI.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids,exclude("OLE_COLOR","ICommand","IProgressDialog")
#import "D:/Program Files/ArcGIS/com/esriGeometry.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids,exclude("OLE_COLOR")
#import "D:/Program Files/ArcGIS/com/esriDisplay.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids,exclude("OLE_COLOR")
#import "D:/Program Files/ArcGIS/com/esriOutput.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids,exclude("OLE_COLOR")
#import "D:/Program Files/ArcGIS/com/esriGeoDatabase.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids,exclude("OLE_COLOR","IRow","ICursor")
#import "D:/Program Files/ArcGIS/com/esriCarto.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids,exclude("OLE_COLOR","ITableDefinition","UINT_PTR")
 
 
// additionally for 3D controls
#import "D:/Program Files/ArcGIS/com/esri3DAnalyst.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids
#import "D:/Program Files/ArcGIS/com/esriGlobeCore.olb" raw_interfaces_only, raw_native_types, no_namespace, named_guids
#import "D:/Program Files/ArcGIS/bin/SceneControl.ocx" raw_interfaces_only, raw_native_types, no_namespace, named_guids
#import "D:/Program Files/ArcGIS/bin/GlobeControl.ocx" raw_interfaces_only, raw_native_types, no_namespace, named_guids
 
#pragma warning(pop)


//MainFrm.cpp 文件中

//int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)方法中添加如下代码

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWndEx::OnCreate(lpCreateStruct) == -1)
return -1;


//=AO对象实例化
//-------------------------------------
IAoInitializePtr m_AoInit(CLSID_AoInitialize);// new AoInitializeClass();
esriLicenseStatus ls;
m_AoInit->Initialize(esriLicenseProductCode::esriLicenseProductCodeArcServer,&ls);


CString path=L"";
IPropertySetPtr ipPropertySet(CLSID_PropertySet);
    ipPropertySet->SetProperty(CComBSTR(L"DATABASE"),CComVariant(path));
//
//CComPtr<IWorkspaceFactory> ipWorkspaceFactory;
    //ipWorkspaceFactory.CoCreateInstance(CLSID_ShapefileWorkspaceFactory);
//
//IFeatureLayerPtr ipFeatureLayer;
    //HRESULT hr = ipFeatureLayer.CreateInstance(CLSID_FeatureLayer);
//-------------------------------------
BOOL bNameValid;
// 基于持久值设置视觉管理器和样式

        //.....

}

CMainFrame::~CMainFrame()
{
IAoInitializePtr m_AoInit(CLSID_AoInitialize);
esriLicenseStatus ls;
m_AoInit->CheckInExtension(esriLicenseExtensionCode::esriLicenseExtensionCodeSpatialAnalyst,&ls);
m_AoInit->CheckInExtension(esriLicenseExtensionCode::esriLicenseExtensionCodeDataInteroperability,&ls);
    m_AoInit->CheckInExtension(esriLicenseExtensionCode::esriLicenseExtensionCode3DAnalyst,&ls);


m_AoInit->Shutdown();
m_AoInit=NULL;
}


int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWndEx::OnCreate(lpCreateStruct) == -1)
return -1;


//=AO对象实例化
//-------------------------------------
IAoInitializePtr m_AoInit(CLSID_AoInitialize);// new AoInitializeClass();
esriLicenseStatus ls;
m_AoInit->Initialize(esriLicenseProductCode::esriLicenseProductCodeArcServer,&ls);
m_AoInit->CheckOutExtension(esriLicenseExtensionCode::esriLicenseExtensionCode3DAnalyst,&ls);
m_AoInit->CheckOutExtension(esriLicenseExtensionCode::esriLicenseExtensionCodeDataInteroperability,&ls);
m_AoInit->CheckOutExtension(esriLicenseExtensionCode::esriLicenseExtensionCodeSpatialAnalyst,&ls);


CString path=L"";
IPropertySetPtr ipPropertySet(CLSID_PropertySet);
    ipPropertySet->SetProperty(CComBSTR(L"DATABASE"),CComVariant(path));


//MessageBox("")/m_AoInit->
//
//CComPtr<IWorkspaceFactory> ipWorkspaceFactory;
    //ipWorkspaceFactory.CoCreateInstance(CLSID_ShapefileWorkspaceFactory);
//
//IFeatureLayerPtr ipFeatureLayer;
    //HRESULT hr = ipFeatureLayer.CreateInstance(CLSID_FeatureLayer);
//-------------------------------------
BOOL bNameValid;
// 基于持久值设置视觉管理器和样式

..

}


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:1513708次
    • 积分:16761
    • 等级:
    • 排名:第599名
    • 原创:278篇
    • 转载:373篇
    • 译文:4篇
    • 评论:121条
    最新评论