I'm trying to substitute $structParameter by its low-level version as suggested in the Win32::API doc, this is using something like pack('NC',$size,$aKey).
Win32::API's letter codes and pack()'s letter codes are different, do not use letters from one on the other, always reread the docs for pack and Win32::API. You want 'LP' (L=native (LE) 32 bit, P=pointer to scalar string) for pack. That pack 'L' is a 'I' for Win32::API BTW.
# 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');
Your prototype is wrong. 'C' as a return type either will be a undef, or a mangled something (number or single letter). You probably want 'N' instead of C to save that myCell * as a Perl scalar number.
If you C header prototype is absolutly correct. 'S' and ::Struct won't work. "struct cRefStr key" is a pass by copy parameter, not a pointer or pass by reference. Thats going to require serious hacking on your part to get working since Win32::API can't do pass by copy structs/strings/anything except native machine numbers. I know its possible.
Since that "struct cRefStr" has a size_t and a char *, and is pass by copy now, on 32 bit machine code ONLY (x64 machine code has a different calling convention and something else must be done), replace the 'S' letter with a 'N' and then a 'P', you will not have a struct anymore in Perl but the C function will think it is getting the pass by copy struct. So 'NSN' becomes 'NNPN'.
The recipe for pass by copy struct with ::API on 32 bit machine code is, do a pack() to create the binary packed struct as a scalar string. Then add nulls to the end of the scalar string to align it to a multiple of 4 (I think)(this can also be done with the pack() letter codes during the previous pack). Now do "length($packed)/4", 4 being the byte size of an ::API N on 32 bits, this is the number of Ns you will turn the packed scalar string into an array of scalar numbers, "@structasnums = unpack('L
6', $packedstruct);", then for the prototype to ::API, you put "length($packed)/4" 'N's in a row where that struct is in the C header prototype so it looks like "$obj = new Win32::API('somedll.dll', 'aFunction', 'PPNNNNNNN', 'N');"
. Then you do "$obj->Call($something, $foo1, @structasnums, $lastparam);". To break down the ::API prototype, "'PPNNNNNNN'", P=$something, P=$foo1, NNNNNN=@structasnums, N=$lastparam.
From the last thread you made,
WIN32::API and void*, your running 32 bit cygwin perl with 64 bit ints on x64 Windows.