第一范文网 - 专业文章范例文档资料分享平台

C++CLI调用ArcObjects (2)

来源:用户分享 时间:2020-06-24 本文由雨博韵潇 分享 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

修改头文件stdafx.h,导入ArcObjects相关库

// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently //

#pragma once

#include \

#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers

// Windows Header Files: #include

// TODO: reference additional headers your program requires here #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 \ raw_interfaces_only, raw_native_types, no_namespace, named_guids, exclude(\, \, \)

#import \ raw_interfaces_only, raw_native_types, no_namespace, named_guids,exclude(\) // Load the ArcGISVersion library.

// This code is commonly placed in the StdAfx.h header file. #import \ raw_interfaces_only,no_implementation

添加一个头文件NAoHelper.h

修改后的头文件如下:

#ifndef AOHELPER_H_ #define AOHELPER_H_ #ifdef NAOHELPER_EXPORTS

#define DAPI __declspec(dllexport) #else

#define DAPI __declspec(dllimport) #endif

//导出这个类

class DAPI AoHelper { public: }; #endif

AoHelper(); ~AoHelper(); int line_test(); int InitializeAo();

private:

打开NAoHelper.cpp,修改后如下:

// NAoHelper.cpp : Defines the exported functions for the DLL application. //

#include \ #include \

AoHelper::AoHelper() { }

AoHelper::~AoHelper() { }

int AoHelper::InitializeAo() {

esriLicenseStatus ls; HRESULT h=

IAoInitializePtr m_AoInit;//(CLSID_AoInitialize); m_AoInit.CreateInstance (CLSID_AoInitialize); ArcGISVersionLib::IArcGISVersionPtr VARIANT_BOOL succeeded;

if (FAILED(ipVer->LoadVersion(ArcGISVersionLib::esriArcGISDesktop ,

return 0;

ipVer(__uuidof(ArcGISVersionLib::VersionManager));

::CoUninitialize(); ::CoInitialize(NULL); //不初始化也可以 //InitializeAo();

L\,&succeeded)))

m_AoInit->Initialize(esriLicenseProductCode::esriLicenseProductCodeEngineGeoDB ,&ls); }

int AoHelper::line_test() {

IPointPtr ipPt1(CLSID_Point); IPointPtr ipPt2(CLSID_Point); ipPt1->PutCoords(1, 2); ipPt2->PutCoords(2, 3); return 0;

}

ILinePtr ipLine(CLSID_Line);

for(long i = 0; i <= 10000000; i++) { }

return 0;

ipLine->PutCoords(ipPt1,ipPt2);

编译,完成本地c++调用AO封装类库

4 添加新项目,命名为NAoWrapper,利用C++/CLI对NAoHelper进行封装的库,以便于C#调用

编辑包含文件(头文件)目录

修改头文件NAoHelper.h

// NAoWrapper.h

搜索“diyifanwen.net”或“第一范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,第一范文网,提供最新高中教育C++CLI调用ArcObjects (2)全文阅读和word下载服务。

C++CLI调用ArcObjects (2).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/wenku/1100362.html(转载请注明文章来源)
热门推荐
Copyright © 2018-2022 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top