This is called a "call back" and you can't do it with Win32::API. Go grab the FFI.pm module (and yell at ActiveState and/or IndigoStar if they still don't have a binary version of this module for you).

The second argument would need to be of type "N", not "P" (Win32::API's "P" is mostly only useful for '\0'-terminated strings), and would need to be the address of a C subroutine (well, it could be a subroutine in any number of languages provided that it follows the appropriate Win32 calling conventions, which means it can't be a Perl subroutine).

You can also use FFI.pm instead of Win32::API for accessing arbitrary subroutines from DLLs (or other types of shared libraries since FFI.pm is portable, very much unlike Win32::API). I'm not a big fan of the some aspects of the design of Win32::API anyway, though I suspect I'll find that FFI.pm and C::Dynalib (the other portable replacement for Win32::API that also existed before it) have their own things that annoy me once I use them enough.

        - tye (but my friends call me "Tye")

In reply to (tye)Re: Inspecting messages using Win32::API by tye
in thread Inspecting messages using Win32::API by mtaylor

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.