delphi 调用C#动态库问题

chenwenwen3 2011-09-20 01:40:44
现有一个接口说明:
函数名:getcompinfo
入口参数:无。
出口参数:字符串。
格 式:getcompinfo(szOut)
函数返回值:0,正确;非0整数,错误码。
 出口参数说明:
序号 数据项 类型 长度 说明
1 编号 C 20
2 名称 C 200

我用delphi写的代码:
function getcompinfo(var szout:pchar):integer;stdcall;external 'abc.dll'
procedure aaa();
var
str : pchar; i:integer;
begin
if getcompinfo(str) = 0 then
showmessage(str);
end;

跟踪得到的结果:str:Inaccessible value
看起来是内存不足,请帮忙看看如何解决。谢谢。

...全文
236 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
快乐老猫 2011-09-23
  • 打赏
  • 举报
回复
你确认是c#?
那个东西需要.net的,再有,他可能是activex dll,非标准dll
chenwenwen3 2011-09-20
  • 打赏
  • 举报
回复
顶下,在线等
chenwenwen3 2011-09-20
  • 打赏
  • 举报
回复
同意1楼,但依然有问题
yushf 2011-09-20
  • 打赏
  • 举报
回复
那就试试这样是否可以


function getcompinfo(out szout: WideString): integer;stdcall;external 'abc.dll'
procedure aaa();
var
str: WideString;
begin
if getcompinfo(str) = 0 then
showmessage(str);
end;
chenwenwen3 2011-09-20
  • 打赏
  • 举报
回复
procedure aaa();
var
str : pchar; i:integer;
begin
Getmem(str,220);
if getcompinfo(str) = 0 then
showmessage(str);
end;

这样写也还是一样啊
浩南_哥 2011-09-20
  • 打赏
  • 举报
回复
出口参数说明:
序号 数据项 类型 长度 说明
1 编号 C 20
2 名称 C 200
需要分配220的空间,你就声明了一个str:Pchar,没有分配空间

1,183

社区成员

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

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