By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,848 Members | 1,375 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,848 IT Pros & Developers. It's quick & easy.

Pointer parameter to a mapped C dll function

P: 1

I'm a new Perl programmer and I'm using the Win32::API module to use functions of a C dll.
I'm using ActivePerl 5.8.8.

Here is the C code of the function I need to use:
Expand|Select|Wrap|Line Numbers
  1. const char* DecodeSomething(GUInt64 time, GUInt16 msgId, GUInt16 bodyLength, GUInt8 dxpNum, GUInt8* bodyData);
So I mapped this function in Perl like this:
Expand|Select|Wrap|Line Numbers
  1. $decodeSomething = Win32::API->new($dll, 'DecodeSomething', 'IIIIP', 'P');
And I try to use it like this:

Expand|Select|Wrap|Line Numbers
  1. $data = [0x03, 0x00, 0x13, 0x15, 0x3B];
  2. $decodedRecord = $decodeSomething->Call(0xB4B65BBB, 0x0F, 0x20, 0x1, $data);
But running this code raise a "Perl command line interpreter error'.

I think that the error is related to passing a char pointer and/or receiving a char pointer. I am not sure if my Perl translation of the C function header is correct: $decodeSomething = Win32::API->new($dll, 'DecodeSomething', 'IIIIP', 'P');, especially using the P parameter type.
Note that using other functions in this dll with only integer parameters works just fine.

Any hint would be greatly appreciated.

Thanks in advance for your help.
Apr 24 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.