Perl Win32::API() call() function -
dear all, trying value of char pointer or string in return of call() function dll. dll having function randomdec(long , int*) , returns string. call using win32::api(). have tried , didn't succeed. plz help
use win32::api; @lpbuffer = " " x 20; $pp= \@lpbuffer; $xy=0; $ff= \$xy; $fun2 = new win32::api('my.dll','randomdec','np','**p**')or die $^e; $pp = $fun2->call(4,$ff);
how using $pp ?
there multiple errors in code.
-
my @lpbuffer = " " x 20; $pp= \@lpbuffer;
=> my $pp = " " x 20;
you mixing arrays strings, , don't need perl ref c ptr. similar int*.
- n number not long. l unsigned, need signed, l.
use win32::api; $pp = " " x 20; # alloc string $xy = 0; # alloc int $fun2 = new win32::api('my.dll','randomdec','lp','p') or die $^e; $pp = $fun2->call(4,$xy);
i haven't check if win32::api can lvalue assignment char*. not, $pp foreign pointer string after call, , prev. pv slot $pp lost, , inaccessible perl. ffi's , winapi return int, not strings. strings via sideeffects, function arg.
Comments
Post a Comment