Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by fenonn (Chaplain)
on Jun 24, 2002 at 15:55 UTC ( [id://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';

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2025-06-19 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.