package mymod;
use warnings;
use Win32::API;
#### define the structure
Win32::API::Struct->typedef( POINT => qw{
LONG x;
LONG y;
});
#### import an API that uses this structure
Win32::API->Import('user32', 'BOOL GetCursorPos(LPPOINT lpPoint)');
#### create a 'POINT' object
my $pt = Win32::API::Struct->new('POINT');
#### call the function passing our structure object
GetCursorPos($pt);
#### and now, access its members
print "The cursor is at: $pt->{x}, $pt->{y}\n";
1;
####
D:\pscrpt>perl mymod.pm
The cursor is at: 584, 1017
D:\pscrpt>perl mymod.pm
The cursor is at: 213, 542
####
use warnings;
use mymod;
####
D:\pscrpt>perl test.pl
Win32::API::parse_prototype: WARNING unknown output parameter type 'BOOL' at D:/
perl58_M/site/5.8.8/lib/Win32/API.pm line 273.
Use of uninitialized value in concatenation (.) or string at mymod.pm line 21.
Use of uninitialized value in concatenation (.) or string at mymod.pm line 21.
The cursor is at: ,