用旧用Borland C一个Visual C ++ DLL? [英] Using a Visual C++ DLL in old Borland C?

查看:128
本文介绍了用旧用Borland C一个Visual C ++ DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得支持C语言编写的旧的应用程序使用旧的Borland的编译器(BC 5)。

I've got to support an old app written in C using the old Borland Compiler (BC 5).

不幸的是,旧的TCP / IP,我们会使用库已开始显现它的年龄,并具有Vista和功放的问题; Win7的机器。

Unfortunately the old TCP/IP library that we'd used is starting to show it's age and is having problems with Vista & Win7 machines.

我有一个函数新的库可用于微软的Visual C ++,我想用它来制作一个DLL,这将是从Borland C来调用。

I have a new library of functions available for MS Visual C++, and I'd like to use that to make a DLL that would be callable from the Borland C.

所以,我有2个问题:
1)如何使Visual C ++ DLL从Borland的C程序调用,并
2)如果是可调用的,如何从普通的旧的C调用C ++函数?

So, I have 2 issues: 1) how to make a Visual C++ DLL callable from a Borland C program, and 2) if it is callable, how to call the C++ functions from plain old C?

在理想情况下,整个项目应转换到Visual C,但也有很多传统的功能也许会让该项目的一大创举!我正在寻找一个快速的补丁来保持它活着的一段时间:)

Ideally, the entire project should be converted to Visual C, but there a lot of legacy features that'll make that project a major undertaking! I'm looking for a quick patch to keep it alive for a while longer :)

史蒂夫

推荐答案

编写使用Visual C ++暴露了其作为STDCALL的Windows的C函数接口的DLL。 Windows API函数也同样做。您在接口公开这些功能将执行你需要在你的程序更换功能。该DLL中,调用新的MS VC ++与放弃库。

Write a DLL using Visual C++ that exposes its interface as Windows STDCALL C functions. Windows API functions are done similarly. Those functions you expose in the interface will perform the functions you need to replace in your program. Inside the DLL, call the new MS VC++ library with abandon.

因此​​,要获得一个函数,调用从C和使用S​​TDCALL堆栈协议做这样的事情:

So to get a function that is callable from C and uses STDCALL stack protocol do something like this:

的externCINT __stdcall富();

您还必须将信息添加到从DLL导出函数。你可能会在声明中这样明确地做到这一点:

you'll also have to add information to export the function from the DLL. You might do this explicitly in the declaration as such:

的externC__declspec(dllexport)的INT __stdcall富();

但是,你需要使用你的BORLANDC code单独的头文件(其中可能有用于指定DLL的导入部分和STDCALL部分不同的语法)。在Visual C ++你在客户端使用的声明看起来是这样的:

But you'll need a separate header file for use in your BorlandC code (which probably has different syntax for specifying the DLL import part and the STDCALL part). In Visual C++ the declaration you'd use in the client would look something like:

的externC__declspec(dllimport的)INT __stdcall富();

这篇关于用旧用Borland C一个Visual C ++ DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆