- 论坛徽章:
- 0
|
原帖由 flw 于 2005-1-6 19:25 发表 ![]()
to 楼上:
我正准备等融会贯通之后,写一些 Perl/C 混合编程的系列文章呢。
我准备分成三部分:
1,利用 C 语言编制模块来扩展 Perl 的功能。
2,在 Perl 中调用 C 语言书写好的动态/静态链接库(就是这个帖 ...
我想通过Win32::API来调用我的dll中的函数。如果参数是integer类型,能够正常调用,返回正确的计算结果。但是,如果参数是double类型,就会报错!
"Perl Command Line Interpreter has encountered a problem and needs to close. We are sorry for the inconvenience"
是不是Win32::API不支持double类型的参数?
#这个能正确调用
my $function=Win32::API->new('TestDLL', 'int foo1(int P, int T)');
my $return=$function->Call(100, 200);
#这个调用会出错
my $function2=Win32::API->new('TestDLL', 'double foo2(double P, double T)');
my $return2=$function2->Call(10.0, 20.0);
刚刚测试《Perl高级编程(Profssional Perl Programming)》中的例子
use Win32::API;
# import the cos function
$cos = new Win32::API('msvcrt', 'cos', 'D', 'D');
# $cos is an object, use the Call() method on it
$result = $cos->Call(2.0);
print "cos(2.0) = $result\n";
仍然没有成功!
请高手们解答一下。 |
|