'int HCE300_Read(int TrackNo(int TrackNo, char *ReadData )');

my @strip = $readdevice->Call(2,\@in);

You cannot pass a perl array, nor a reference to one, using Win32::API. The Read() function is expecting a pointer to a character buffer: char *ReadData and the way to do that is pass a pre-initialised scalar. Also, the function returns a single integer: int HCE300_Read(..., assigning that to a perl array will work, but is pretty pointless.

Something like this might work (but since I don't have that DLL or whatever device it is talking to, I cannot test it):

my $buffer = chr(0) x 2**16; ## Hopefully it won't return more than 64 +K? my status = $readdevice->Call( 2, $buffer ); ### Now check the status and if the call was successful, ### use the contents of $buffer. Though how you will know ### how much data the call actually returned is an open question?

If that also bottles out you could try using a larger buffer. If it still fails, you'll need to know more about the code you are trying to call.

In all seriousness, trying to do this kind of thing with limited C knowledge and no information about the code you are trying to call is an exercise in frustration. For example, if the DLL was compiled using the wrong calling convention, then you will never be able to call it successfully with Win32::API.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re: Correct call for dll with Win32::API by BrowserUk
in thread Correct call for dll with Win32::API by walto

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.