typedef struct cRefStr { size_t length; char const* data; } cStrRef; #### Win32::API::Struct->typedef(CSTRREF =>qw{int n; char* buffer}); #### # Sub all # cTblAtKey -> findInTableByKey # cTbl -> myTable # cCell -> myCell # ctbl_v2 -> myDll my $aKey = "UserName"; print $aKey."\n"; my $lengthaKey = length($aKey); print $lengthaKey."\n"; Win32::API::Struct->typedef(CSTRREF =>qw{int n; char* buffer}); my $structParameter = Win32::API::Struct->new('CSTRREF'); $structParameter->{n}=$lengthaKey; $structParameter->{buffer}=$aKey; # C function defined as: # myCell* findInTableByKey(myTable that, struct cRefStr key, unsigned offset); # with: # struct myCell { # unsigned char opaque[10]; #}; my $aKeyFunc = Win32::API->new("myDll.dll",'findInTableByKey', 'NSN','C','_cdecl'); if(not defined $aKeyFunc) { die "Couldn't load the function findInTableByKey from the dll"; } $cellPtr = $aKeyFunc->Call($outputTable,$structParameter,0); #### #### define the structure Win32::API::Struct->typedef( POINT => qw{ LONG x; LONG y; }); #### import an API that uses this structure my $getCursor = new Win32::API('user32', 'GetCursorPos','S','N'); #### create a 'POINT' object my $pt = Win32::API::Struct->new('POINT'); #### call the function passing our structure object $getCursor->Call($pt); #### and now, access its members my ($x, $y) =($pt->{x}, $pt->{y}); print "The cursor is at: $x, $y\n"; #### #### import an API that uses this structure my $getCursor = new Win32::API('user32', 'GetCursorPos','S','N'); #### create a 'POINT' object $lpPoint=pack('LL',0,0); #### call the function passing our structure object $getCursor->Call($lpPoint); #### and now, access its members my ($x,$y) = unpack('LL',$pt); print "The cursor is at: ".$x.", ".$y."\n";