It turns out that my entire trip to Inline-land was useless1, because Win32::SerialPort doesn't work for some reason if I use it.

However, I tried Win32::API again as a last resort, and it turned out that it works (and it doesn't crash) if and only if I import the functions like this:

my $RegisterClient2 = Win32::API->new($DLL, 'RegisterClient2', 'PP', ' +I', '_cdecl');

So my DLL was compiled with the _cdecl convention, and that's why it failed earlier.

1) not entirely useless, because I used to think that I can't use Inline on Windows at all. Now that I saw that it works, I have plans to rewrite some of the speed-critical parts of my earlier applications.

2) I agree that the DLL writer's version of Hungarian notation is confusing, but I can't do anything about it. I decided to go with it to stay in sync with the docs.

In reply to Re^2: Calling a function form an external DLL with Inline::C on windows by Anonymous Monk
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.