You can't use \$ah with Win32::API.

The "P" type for parameters means that the address of the string in the variable is passed in. If you pass in \$ah for that argument, then you'll probably be passing in the address of a string like "SCALAR(0x1c7d220)".

Just pass in $ah and the C code will get a pointer to the string (which you correctly initialized to a 4-byte buffer) and can stuff the pointer into that buffer. Now, for ace_set_file, you want to pass the C pointer that got stuff into that string. This means that you can't use "P" for the first argument to ace_set_file, because it can only be used to pass the pointer to a Perl string and that pointer does not point to a Perl string.

Instead, use the argument type of "N" (for ace_set_file's first argument) and do:     $ah= unpack("L",$ah); after the call to ace_init_addr.

Finally, I suggest you use strict which means you need to change code like [P, I, P] to something more like ["P","I","P"] or [qw(P I P)], despite the bad examples in the Win32::API documentation.

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

In reply to (tye)Re: Win32::API help by tye
in thread Win32::API help by Eshock

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.