Delphi 如何调用 VC 的类的成员函数(二) --- 内存模式

本文详细介绍了如何在Delphi中调用VC++编译的DLL类函数,通过实例化C++类并导出成员函数,展示了在Delphi中声明对应的函数,并成功调用这些函数的过程,实现跨语言的函数调用。

https://blog.youkuaiyun.com/dbyoung/article/details/94576926  这篇文章中,
调用 VC 的 C++ Class 类导出的 DLL 函数时,需要在 VC 中,对对象进行实例化。
不在 VC 中实例化,在 Delphi 实例化可不可行?答案是肯定的。

譬如 C++ Class Dll:

// 这是已导出类的构造函数。
CppDll::CppDll()
{
    return;
}

int CppDll::MyAdd(int a, int b)
{
    return a + b;
}

void CppDll::ShowMSG()
{
    ::MessageBoxA(0, (LPCSTR)"Delphi 调用 VC 类的成员函数", (LPCSTR)"系统提示:", MB_OK);
}

用  depends 查看导出函数
x86:

public: __thiscall CppDll::CppDll(void)
public: class CppDll & __thiscall CppDll::operator=(class CppDll &&)
public: class CppDll & __thiscall CppDll::operator=(class CppDll const &)
public: int __thiscall CppDll::MyAdd(int,int)
public: void __thiscall CppDll::ShowMSG(void)

x64:

public: __cdecl CppDll::CppDll(void) __ptr64
publ
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

dbyoung

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值