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

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;
// 基于持久值设置视觉管理器和样式

..

}


阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭