免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1624 | 回复: 0
打印 上一主题 下一主题

Win32::API DLL Point 变量传递问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2014-01-26 21:23 |只看该作者 |倒序浏览
Hi All,
我遇到一个Perl调用外部DLL函数传递指针变量的问题。
我查阅到Win32::API 之中,关于调用dll 之中有指针变量的部分,
  1. P: value is a pointer (to a string, structure, etc...) padding out the buffer string is required, buffer overflow detection is performed. Pack and unpack the data yourself. If P is a return type, only null terminated strings or NULL pointer are supported. If P is an in type, NULL is integer 0. undef, "0", and ""+0 are not integer 0, "0"+0 is integer 0.
  2. It is suggested to not use P as a return type and instead use N and read the memory yourself, and free the pointer if applicable. This pointer is effectively undefined after the C function returns control to Perl. The C function may not hold onto it after the C function returns control. There are exceptions where the pointer will remain valid after the C function returns control, but tread at your own risk, and at your knowledge of Perl interpreter's C internals.
复制代码
这段描述的内容我不太理解,我尝试使用以下代码将指针传递进入,Card.dll为一个外部DLL,但是无法从这个变量获得返回结果,
  1. [code]my $cs = new Win32::API('Card', 'Card_Set', 'P', 'I');
  2. my $b = 1;
  3. my $err = $cs->Call($b);
  4. print $b;
复制代码
[/code]
然后我查阅到有可能是C++的指针类型与perl指针有差,perl传递的地址与进入dll以后的地址不一致,所以我无法拿到需要的结果,从以上关于指针参数描述的要求,他们建议我们自己查找内存得到结果,不知道关于这一块,大家是否有类似的经验可以帮助?我发现关于Perl的技术文章随着时间的逝去,很多服务器上的文章都在消逝,有些文章已经查不到了,虽然很有用。
谢谢各位。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP