首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > PB >

PB中调用DLL,VC怎么定义参数类型

2012-03-16 
PB中调用DLL,VC如何定义参数类型PB中调用DLL,PB中定义外部函数,如下:public function ulong fix(long a,lo

PB中调用DLL,VC如何定义参数类型
PB中调用DLL,PB中定义外部函数,如下:
public function ulong fix(long a,long b,ref ulong c) library "DLL.DLL" alias for "Fix"
public function ulong fix(long a,long b,ref string c) library "DLL.DLL" alias for "Fix"
其中以ref ulong、ref string 返回的参数,在DLL里参数c该定义成什么类型,使得ulong和string都能正确接收?


[解决办法]
如果你的dll是用vc写的话
pb vc
ref ulong unsigned long *
ref string char *
[解决办法]
刚才试了:
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@@YGHHHH@Z @14 private
fix2 = ?fix@@YGHHHPAD@Z @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里再进行一次封装,使其具有一个接口

热点排行