Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-03-29 11:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found