Perl Win32::API() return type -


can give example of how string can returned call using win32::api() function? need return string , print using $val. please give example if same can handled using pointer return type.

use win32::api;   $res = new win32::api('abc.dll','myfun','_argument type list_','_return type list_')or die $^e;   $val= $res->call();    print ($val); 

the documentation win32::api's call() method suggests must pass call() scalar used buffer store returned value; call() return whether call succeeded or not.

example:

my $return_buffer = " " x 80; if ($res->call(80, $return_buffer)) {     print "ok, api call returned '$return_buffer'\n"; } else {     print "the api call failed reason.\n"; } 

edit: quoting the docs completeness:

the 2 parameters needed here length of buffer hold returned temporary path, , pointer buffer itself. numerical parameters, can use either constant expression or variable, while pointers must use variable name (no perl references, plain variable name). note memory must allocated before calling function, in c. example, pass buffer of 80 characters gettemppath(), must initialized before with:

$lpbuffer = " " x 80; 

this allocates string of 80 characters. if don't so, you'll runtime exception errors, , nothing work. call should therefore include:

$lpbuffer = " " x 80; $gettemppath->call(80, $lpbuffer); 

and result stored in $lpbuffer variable. note don't need pass reference variable (eg. don't need \$lpbuffer), if value set function.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -