Perl workshop in beijing

| 7 Comments
Now,the perl workshop in beijing is starting. 来自世界各国的朋友欢聚一堂,开始了perl的盛宴。

7 Comments

您好!
很高兴能再perl大会上听到您的演讲,很遗憾由于有事没能和您当面交流。大会上您说的可以安排一个面试的机会,不知道现在和您联系可不可以。
我的MSN是lifuxue223521@hotmail.com
QQ是 236130132

期待您的消息,谢谢!

您好,可以的。
您感兴趣的话,可以先把简历发到我的邮箱 junliang.li#alibaba-inc.com。

我想问个问题,我想通过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);

The third parameter, the input parameter list, specifies how many arguments the function wants, and their types. It can be passed as a single string, in which each character represents one parameter, or as a list reference. The following forms are valid:

"abcd"
[a, b, c, d]
\@LIST

But those are not:

(a, b, c, d)
@LIST

The number of characters, or elements in the list, specifies the number of parameters, and each character or element specifies the type of an argument; allowed types are:

I: value is an integer (int)
N: value is a number (long)
F: value is a floating point number (float)
D: value is a double precision number (double)
C: value is a char (char)
P: value is a pointer (to a string, structure, etc...)
S: value is a Win32::API::Struct object (see below)
K: value is a Win32::API::Callback object (see Win32::API::Callback)

Our function needs two parameters: a number (DWORD) and a pointer to a string (LPSTR):

$GetTempPath = new Win32::API('kernel32', 'GetTempPath', 'NP', ...

Then

The fourth and final parameter is the type of the value returned by the function. It can be one of the types seen above, plus another type named V (for void), used for functions that do not return a value. In our example the value returned by GetTempPath() is a DWORD, so our return type will be N:

$GetTempPath = new Win32::API('kernel32', 'GetTempPath', 'NP', 'N');

Now the line is complete, and the GetTempPath() API is ready to be used in Perl. Before calling it, you should test that $GetTempPath is defined, otherwise either the function or the library could not be loaded; in this case, $! will be set to the error message reported by Windows. Our definition, with error checking added, should then look like this:

$GetTempPath = new Win32::API('kernel32', 'GetTempPath', 'NP', 'N');
if(not defined $GetTempPath) {
die "Can't import API GetTempPath: $!\n";
}

I don't know if you can understood .

这个我看过,但是没能成功!我觉得Win32::API可能不支持double类型的参数和返回值。
你能不能试验确认一下?

刚刚测试《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";

仍然没有成功!你试一试,能不能行?

你那个测试提示什么错误?
我一般在linux下,现在没有windows平台。

Leave a comment

Archives

Recent Comments

  • Cnangel: 你那个测试提示什么错误? 我一般在linux下,现在没有windows平台。 read more
  • WASPCN: 刚刚测试《Perl高级编程(Profssional Perl Programming)》中的例子 use Win32::API; # import the cos function read more
  • WASPCN: 这个我看过,但是没能成功!我觉得Win32::API可能不支持double类型的参数和返回值。 你能不能试验确认一下? read more
  • Cnangel: The third parameter, the input parameter list, specifies how many read more
  • WASPCN: 我想问个问题,我想通过Win32::API来调用我的dll中的函数。如果参数是integer类型,能够正常调用,返回正确的计算结果。但是,如果参数是double类型,就会报错! "Perl Command Line Interpreter has encountered a problem and read more
  • Cnangel: 您好,可以的。 您感兴趣的话,可以先把简历发到我的邮箱 junliang.li#alibaba-inc.com。 read more
  • 李付学: 您好! 很高兴能再perl大会上听到您的演讲,很遗憾由于有事没能和您当面交流。大会上您说的可以安排一个面试的机会,不知道现在和您联系可不可以。 我的MSN是lifuxue223521@hotmail.com QQ是 236130132 期待您的消息,谢谢! read more

Pages

Powered by Movable Type 5.2.2

December 2012

Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          

Recent Assets

  • dish_st4.png
  • dish_m5.png
  • dish_3.png
  • dish_two.png
  • dish_6.png
  • dish_1.png.png
  • 照片1028 105.jpg
  • 照片1028 088.jpg
  • 照片1028 084.jpg
  • 照片1028 081.jpg
Creative Commons License
This blog is licensed under a Creative Commons License.

About this Entry

This page contains a single entry by Cnangel published on September 19, 2009 3:34 PM.

重回校园的感觉 was the previous entry in this blog.

感冒了 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.