在PB中定义如下外部函数
public function ulong fix(long a,long b,ref string c) library "myDLL.DLL" alias for "Fix"
public function ulong fix(long a,long b,ref ulong c) library "myDLL.DLL" alias for "Fix"
注意参数c的类型不同
我再DLL中如何写一个函数Fix(long ,long b,string/long c),让PB能可以根据参数类型不同自动去执行Fix的不同代码,我不想写fix1(long a,long b,ref string c)、fix2(long a,long b,ref long c) 这样2个函数,只想用一个函数来实现,C代码如何写?请各位高手指点!!
------解决方案--------------------
这个得试试才知道
------解决方案--------------------
不可以,应在PB中判断调用哪个函数,就是说还是:fix1,fix2。。。。。
------解决方案--------------------
VC里面难道不支持函数重载?
------解决方案--------------------
刚才试了:
vc的两个函数
PBTEST_API int __stdcall fix (int a,int b,char* c);
PBTEST_API int __stdcall fix (int a,int b,int c);
int __stdcall fix(int a,int b,int c)
{
return 0;
}
int __stdcall fix(int a,int b,char* c)
{
return 1;
}
但是定义导出时必须不同
fix1 = ?fix@@[email protected] @14 private
fix2 = ?fix@@[email protected] @15 private
PB:
public function ulong fix1(long a,long b,ref ulong c) library "pbtest.DLL"
public function ulong fix2(long a,long b,ref string c) library "pbtest.DLL"
ulong ls_a
ulong a,b
ulong c
string d
ls_a = fix1(a,b,ref c)
messagebox('',ls_a)
ls_a = fix2(a,b,ref d)
messagebox('',ls_a)
执行一切顺利
所以你应该考虑在pb里再进行一次封装,使其具有一个接口