in reply to Correct call for dll with Win32::API
'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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Correct call for dll with Win32::API
by walto (Pilgrim) on Dec 04, 2008 at 18:07 UTC | |
by BrowserUk (Patriarch) on Dec 04, 2008 at 20:14 UTC |