Hello monks,

I have a DLL, from which I want to call a function with the following signature (as specified in the .h file that comes with the DLL):
short WINAPI foo(short a, short b, short c, short d)
Importing (specifying SHORT as the type of all arguments in the new 'C declaration parsing' version, or 'ssss' in the old style) with Win32::API::Import seems to go fine. However, when I actually call the imported function, I get an access violation message box.

Curiously, when I declare the arguments to be integers ('iiii'), there's no access violation, although I'm still not sure I get back the same answer.

1) Has anyone run into such a problem ? What can cause it ?

2) How is the call actually executed with Win32::API, re argument packing ? Are they all appended into one big lump of bytes ?

3) My DLL comes from a 3rd party library for controlling a certain PCI card. They supply the DLL, the .h files and a .LIB import file for simpler linking from C/C++. C++ linking of this DLL works fine, and according to them it should also work without problems in VB, Delphi and LabView. So I suppose nothing should prevent it from working in Perl with Win32::API ? Should the DLL be compiled in some special way to work with Win32::API, or does it work with all DLLs ? Thanks in advance

In reply to Win32::API and 'short' arguments by spurperl

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.