Calling a function from a win32-DLL in perl

Calling a function from a win32-DLL in perl

am 27.12.2007 13:17:36 von Tom Gur

Hi,

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

Thanks,
Tom

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

am 27.12.2007 14:20:25 von Kira Yamato

On 2007-12-27 07:17:36 -0500, Tom Gur said:

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

use Win32::API;

--

-kira

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

am 27.12.2007 15:14:01 von Tom Gur

On Dec 27, 3:20 pm, Kira Yamato wrote:
> On 2007-12-27 07:17:36 -0500, Tom Gur said:
>
> > Hi,
>
> > How can I, within a perl script, call a certain function from a win32
> > DLL file ?
>
> > Thanks,
> > Tom
>
> use Win32::API;
>
> --
>
> -kira

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

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

am 27.12.2007 22:29:46 von Ben Morrow

Quoth Tom Gur :
> On Dec 27, 3:20 pm, Kira Yamato wrote:
> > On 2007-12-27 07:17:36 -0500, Tom Gur 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