Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Calling a C API in a dll from Perl on Windows

by fenonn (Chaplain)
on Jun 24, 2002 at 15:55 UTC ( #176838=note: print w/ replies, xml ) Need Help??


in reply to Calling a C API in a dll from Perl on Windows

I think the best bet is to go with using Win32::API. I have used this module to easily allow my perl program to control Winamp. Here is a short example that uses a function in the user32.dll to send a Win32 message to Winamp to obtain its playback status.

#!/usr/bin/perl -w use strict; use Win32::GUI; use Win32::API; my $winampHandle = Win32::GUI::FindWindow("Winamp v1.x", ""); print "Handle: $winampHandle\n"; my $sendMessage = new Win32::API("user32", "SendMessageA", ['N','N','N +','N'], 'N'); my $playStatus = $sendMessage->Call($winampHandle,1024,2,104); print $playStatus == 0 ? 'stopped' : $playStatus == 1 ? 'playing' : 'p +aused';


Comment on Re: Calling a C API in a dll from Perl on Windows
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://176838]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2014-08-30 07:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (291 votes), past polls