Re: Calling a function from a win32-DLL in perl




Quoth Tom Gur <gur.tom@xxxxxxxxx>:
On Dec 27, 3:20 pm, Kira Yamato <kira...@xxxxxxxxxxxxx> wrote:
On 2007-12-27 07:17:36 -0500, Tom Gur <gur....@xxxxxxxxx> said:

How can I, within a perl script, call a certain function from a win32
DLL file ?

use Win32::API;

IIRC this only works for __stdcall functions, which applies all the
Win32 API functions in e.g. user32.dll, but not to ordinary C functions
exported from DLLs. These can only be called by using XS; the Inline::C
module provides a convenient way to wrap them if you don't want to write
XS, but it requires a C compiler. In principle chromatic's P5NCI ought
to be a good solution, but it doesn't work under Win32 yet.

Is there a way to do it using standard perl modules (without adding
modules) ?

Well, in *principle* you could use Dynaloader directly, but passing the
arguments and retrieving the return value would be well-nigh impossible.
Win32::API is installed with both ActivePerl and Strawberry Perl, so all
Win32 perl installations should include it.

Ben

.