Accessing a .dll function via Win32::API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gfzFabian
    New Member
    • May 2012
    • 2

    Accessing a .dll function via Win32::API

    Dear PERL friends,
    would be very grateful for a solution:

    I want to hand over arguments to a .dll function per reference but seem to fail somehow.

    I have self-explaining (hopefully) comments in the code.

    Thanks again,
    Fabian

    CODE:

    Code:
    # header stuff
    use feature ':5.10';
    binmode(STDOUT, ":encoding(cp850)");
    use Win32::API;
    # header end
    
    
    
    # *******************************
    # -> THE MAGIC SHOULD START HERE:
    # *******************************
    
    # invoke the function 'DOTP' within the Carbondioxide.dll
    # with 2 arguments, Double precision 'DD' and a Double precision return 'D'
    
    # (shall calculate the density of co2 at given temperature in Kelvin and pressure in MPa)
    
    # !!! ARGUMENTS shall be handed over BY REFERENCE whereas
    # RETURN values of the function are given back BY VALUE
    
    $function=Win32::API->new('CARBONDIOXIDE','DOTP','DD','D');
    
    $T=300;
    $P=6;
    $return = $function->Call(\$T,\$P ); # CRASHES here for unknown reason

    say $return."\n";
    Last edited by numberwhun; May 15 '12, 04:08 AM. Reason: Please use Code tags around code in the forums. Please read the FAQ on how to post a question if you are not sure how to.
  • gfzFabian
    New Member
    • May 2012
    • 2

    #2
    S O L V E D:
    Last edited by Niheel; May 8 '12, 03:38 PM. Reason: Can you post a more detailed solution? You can leave the link as a reference.

    Comment

    Working...