Using Microsoft Visual C++ DLLs with C++Builder

As powerful as C++Builder is, the majority of DLLs developed and used within the software community are built using Visual C++. Therefore, chances are you will need to interface your C++Builder code with a Visual C++ DLL. Again, there are two ways for a DLL to attach to an application. Either it can be loaded in dynamically, or it can be loaded in statically if the LIB file associated to the DLL is linked at compile time. If that LIB file is a Microsoft LIB file, the DLL won't be able to load. The reason is because of the compatibility issues between the LIB file format for Visual C++ and C++Builder. Both vendors use different exporting conventions. Microsoft supports the Common Object Format File (COFF), whereas Borland uses the Object Model Format (OMF). Fortunately, there is a way to create a Borland OMF import library file that represents a Microsoft built DLL.

To create a Borland compatible .lib file for a Visual C++ DLL, you can use the COFF2OMF command-line tool from Borland, which resides in the Bin folder under C++Builder. COFF2OMF takes two arguments: the first is the source library's filename; and the second is the destination's filename.

Coff2Omf MyDll.lib MyDll_bor.lib 

In this example, COFF2OMF will generate a new OMF library file called MyDll_bor.lib. Within your C++Builder project, be sure to link using this MyDll_bor.lib file as part of the project file listing.

NOTE

The COFF2OMF utility only works on lib files with simple exported C functions. If C++ classes are exported, it will not work.

If this doesn't work, you need to find out how the functions
are being exported and give them an alias that C++Builder will like. To do this,
first you should use Impdef.exe to create a definition file (or
.def file), which enables you to view all the exported functions' names
and ordinal numbers. Next, modify the exported functions in the .def
file, so the function looks like this:

Old export section
EXPORTS
_Add@8 =_Add @1 New export section
EXPORTS
Add=_Add@8

After you've made the changes to the library, save the .def file. Now you can use Implib.exe on this file to create a new library file that C++Builder should like. Implib.exe also takes two parameters: the destination and the source. For example

Implib MyDll.lib MyDll.def 

Because you now have a library in C++Builder style, you should be able to include it in your project and use the DLL and .lib.

See the VCppProject folder on the CD-ROM that accompanies this book for the complete C++Builder project CallVCppDll.bpr. This uses the Visual C++ DLL mentioned previously.

Using Microsoft Visual C++ DLLs with C++Builder的更多相关文章

  1. FB Flash Builder 安装错误 ERROR: DW050: - Microsoft Visual C++ 2010 Redistributable Package (x86): Install failed

    这个问题很可能是你的 Microsoft Visual C++ 2010 Redistributable Package (x86) 太新的缘故,所以无法安装成功,导致最终的失败. 在控制面板-程序和 ...

  2. Microsoft Visual Studio 2015 下载、注册、安装过程、功能列表、问题解决

    PS:请看看回复.可能会有文章里没有提到的问题.也许会对你有帮助哦~ 先上一张最终的截图吧: VS2015正式版出了,虽然没有Ultimate旗舰版,不过也是好激动的说.哈哈.可能有的小伙伴,由于工作 ...

  3. Microsoft Visual SourceSafe 6.0 无法关联项目

    最近遇到Microsoft Visual SourceSafe 6.0 安装好以后, 无法关联项目,导致无法进行版本控制,研究以后,发现需要运行一个程序,在安装目录下 ..\Visual Source ...

  4. Microsoft Visual Studio 文件识别及其用途简述

    Microsoft Visual Studio IDE开发工具集,目前已推出多个不同版本,从之前的VC4.0到现在的VS2015,各个版本都会或多或少的功能或性能上的修改.提升,具体的改进地方可去官网 ...

  5. Microsoft Visual Studio PDB文件相关事宜

    Microsoft Visual Studio PDB:调试的符号文件,程序数据库 (PDB) 文件保存着调试和项目状态信息,使用这些信息可以对程序的调试配置: 当以 /ZI 或 /Zi(用于 C/C ...

  6. Microsoft Visual Studio 2008 未能正确加载包“Visual Web Developer HTML Source Editor Package” | “Visual Studio HTM Editor Package”

    在安装Microsoft Visual Studio 2008 后,如果Visual Studio 2008的语言版本与系统不一致时,比如:在Windows 7 English System 安装Vi ...

  7. AO安装需要Microsoft Visual Studio 2013?

    从接触ArcGIS9.2到 10.4,在不断升级的 过程中,既给我们带来了很多惊喜,也带来一些麻烦,因为ArcGIS版本不兼容.出于体验,安装了ArcGIS Desktop10.4,AO也得升到10. ...

  8. please wait while windows configures microsoft visual studio professional 2013 [转载]

    2016年5月30日 VS3013安装update 2以后,打开offie出现"please wait while windows configures microsoft visual s ...

  9. [转]SSAS没有注册类 (异常来自 HRESULT:0x80040154 (REGDB_E_CLASSNOTREG)) (Microsoft Visual Studio)的解决办法

    转自:http://www.cnblogs.com/xvqm00/archive/2011/07/15/2107338.html 打开SSAS 数据源视图浏览数据时,提示 没有注册类别 (异常来自 H ...

随机推荐

  1. .net core 使用SignalR实现实时通信

    这几天在研究SignalR,网上大部分的例子都是聊天室,我的需求是把服务端的信息发送给前端展示.并且需要实现单个用户推送. 用户登录我用的是ClaimsIdentity,这里就不多解释,如果不是很了解 ...

  2. 如何使用threejs实现第一人称视角的移动

    在数据可视化领域利用webgl来创建三维场景或VR已经越来越普遍,各种开发框架也应运而生.今天我们就通过最基本的threejs来完成第一人称视角的场景巡检功能.如果你是一位threejs的初学者或正打 ...

  3. PWM原理及其在电源中的应用

    熟悉单机片的同学就应该知道pwm,也就是脉冲宽度调制技术,它是通过对一系列脉冲的宽度进行调制,来获得等效的波形.是利用微处理器的数字输出来对模拟电路进行控制的一种非常有效的技术,因其操作简单,又灵活等 ...

  4. lnmp+tp5安装纪要

    1: lnmp : https://lnmp.org/install.html  官网安装帮助 运行命令:wget http://soft.vpser.net/lnmp/lnmp1.6.tar.gz ...

  5. java8 time包的简单使用

    import com.sun.org.apache.xml.internal.res.XMLErrorResources_tr; import java.text.DateFormat; import ...

  6. hdu 6609 区间条件前缀和 + 二分

    题目传送门//res tp hdu 目的 在尾部逐步插入n个元素,求插入第i个元素时,[1,i)内删去多少个元素,可使前缀和[1,i]不大于m 多测Q [1,15] n [1,2e5] m [1,1e ...

  7. python 之 数据库(视图、触发器、事务、存储过程)

    10.13 视图 1.什么是视图 视图就是通过查询得到一张虚拟表,然后保存下来,下次用的直接使用即可 2.为什么要用视图 如果要频繁使用一张虚拟表,可以不用重复查询 3.如何使用视图 视图记录的增.删 ...

  8. 数据库基础理解学习-Mysql

    1. 简介 数据库,现代化的数据存储存储手段,是一种特殊的文件,其中存储着需要的数据. 特点: 持久化存储 读写速度极高 保证数据的有效性 对程序支持性非常好,容易扩展 2. Mysql (1)具有数 ...

  9. 机器学习之主成分分析PCA原理笔记

    1.    相关背景 在许多领域的研究与应用中,通常需要对含有多个变量的数据进行观测,收集大量数据后进行分析寻找规律.多变量大数据集无疑会为研究和应用提供丰富的信息,但是也在一定程度上增加了数据采集的 ...

  10. 编译 Linux 内核 时出现 Restart config 问题

    scripts/kconfig/conf --silentoldconfig Kconfig * * Restart config... * * * Enable the block layer * ...