有关VC调用DELPHI开发的动态连接库的问题,请帮忙.

liujinwei633 2003-07-26 02:30:01
兄弟我用DELPHI5开发了一个动态连接库,其中输入、输出参数为PCHAR类型,
在使用VC来调用时,有些问题,请问VC中使用什么类型的参数。请各位帮忙解答。
...全文
37 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
liujinwei633 2003-07-30
  • 打赏
  • 举报
回复
我的程序是这样的,请指教
DELPHI中
function test(var teststr: PChar):integer;stdcall;

function test(var teststr: PChar):integer;
begin
Result := 0;
StrPCopy(teststr,'aaaaaaaa');
end;

VC
typedef int (__stdcall * pTest)(char *szStr);

HINSTANCE hLibrary;
pTest Test;
hLibrary=LoadLibrary("test.dll");
if(!hLibrary)
{
AfxMessageBox("can't open dll file");
return;
}
Test=(pTest)GetProcAddress(hLibrary,"test");
char *buffer;
int a= (*Test)(buffer); //此处出错
CString s=buffer;
AfxMessageBox(s);
FreeLibrary(hLibrary);


videohome 2003-07-28
  • 打赏
  • 举报
回复
写动态库最接口最重要的是参数压栈方式,压栈方式有cdecl和stdcall两种.
VC里默认的压栈方式是cdecl,在你写的动态库中要显示声明为其中某一种.
如:
在Delphi里
procedure Fun(var pData:PCHAR);stdcall;

在VC里也要有相应的函数声明
void __stdcall Fun(char* pData);
李_军 2003-07-26
  • 打赏
  • 举报
回复
char *对应Delphi中的pchar
Eastunfail 2003-07-26
  • 打赏
  • 举报
回复
char*对应Delphi中的pchar

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧