It sounds like you completely overlooked my reply in the earlier thread and recreated it from scratch.

So I inserted my $client_id = 0 before calling the function. No good; it crashed

The function expects a pointer to a block of memory that can hold 4 bytes.
You tell Win32::API to pass a pointer to a block of memory.
You provide an integer instead of a block of memory to Win32::API.

I had to do an extra $client_id = unpack "i", $client_id; to get the value I really wanted.

I don't know why this surprises you. How do you expect Win32::API or Perl to know the buffer contains a native integer if you don't tell it.

By the way, I think "l" is more appropriate if you specify "I" to Win32::API.

I got back garbage in the $Ex, etc. variables.

The function expects a pointer to a block of memory that can hold 8 bytes. (I think it's 8. I use pack to create the right amount of memory.)
You tell Win32::API to pass a pointer to a block of memory.
You provide an floating point number instead of a block of memory to Win32::API.

It seems that it can't be a hash element, either.

Nonsense. Win32::API couldn't tell the difference between a scalar and a hash's value even if it tried.

$ perl -MDevel::Peek -e'$x="abc"; %h=(x=>"abc"); sub f { Dump($_[0]) } + f($x); f($h{x});' SV = PV(0x816a040) at 0x817bc40 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x8177bf0 "abc"\0 CUR = 3 LEN = 4 SV = PV(0x816a098) at 0x816c158 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x817d920 "abc"\0 CUR = 3 LEN = 4

In reply to Re: Calling a function from an external DLL with Win32::API on windows: paranormal activity by ikegami
in thread Calling a function from an external DLL with Win32::API on windows: paranormal activity by kikuchiyo

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.