http://qs321.pair.com?node_id=491918

jimbojones has asked for the wisdom of the Perl Monks concerning the following question:

Hello

I'm trying to use a simple windows .dll through the Win32::API utility. Every time I call a C-function that uses arguments, I get an exception that causes Perl to quit. I've broken it down to the following test example.

use strict; use Win32::API; my $winPerlTest = Win32::API->new( 'test', 'PerlTest', 'I', 'I'); die "Can't import API PerlTest: $!\n" unless ( defined $winPerlTest); my $id = 137; my $return; $return = $winPerlTest->Call($id); print $return, "\n"; __DATA__ /* declaration of PerlTest C-function */ int PerlTest(int a) { return a+1; }
If I redefine the PerlTest function to take no input arguments, (i.e. return some static number), it works correctly. Also, the examples given in the POD concerning kernel32.dll functions also work correctly, including those with input arguments. This leads me to suspect I'm missing something when creating the C test.dll

I'm using AS 586.811 and Win32::API v0.41 that I got through PPM from AS.

Thanks in advance, Jim