If int* doesn't work, I would use the following. It's basically the same as what you ended up doing using Inline::C, but in Pure Perl.

use Win32::API qw( ); my $register_client2 = Win32::API->new( $S{DLL_path}, 'RegisterClient2', 'PP', 'I', ); sub register_client2 { my $ip = $_[1]; my $id = pack('l', 0); # Allocate space my $rv = $register_client2->Call($id, $ip); $_[0] = unpack('l', $id); return $rv; } register_client2(my $id, $ip) or die;

If the return value is just a boolean, you could do something more perlish.

sub register_client2 { my ($ip) = @_; my $id = pack('l', 0); # Allocate space $register_client2->Call($id, $ip) or return (); return unpack('l', $id); } my ($id) = register_client2($ip) or die;

Note: psz would indicate char** rather than char*. That's confusing.


In reply to Re: Calling a function form an external DLL with Inline::C on windows by ikegami
in thread Calling a function form an external DLL with Inline::C on windows by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.