Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Win32::API accessing DLL

by ganeshlin (Initiate)
on Sep 07, 2012 at 10:46 UTC ( #992280=perlquestion: print w/ replies, xml ) Need Help??
ganeshlin has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am trying to use a procedure exported by a .dll. I am using Win32::API. $function = new Win32::API('dllfile.dll', 'functionname', 'P','I') || die $!; This returns "The specified procedure could not be found." I tried using dumpbin /exports dllfile.dll I got the same function name but with a suffix _ and prefix @4 _functionname@4 Looking forward for a help in this.

Comment on Win32::API accessing DLL
Replies are listed 'Best First'.
Re: Win32::API accessing DLL
by philiprbrenan (Monk) on Sep 07, 2012 at 13:19 UTC

    Windows has multiple calling conventions for functions. I believe the DLL is exposing different entry points to support these conventions. Please see:

Re: Win32::API accessing DLL
by Corion (Pope) on Sep 07, 2012 at 12:15 UTC
    So, have you tried to import that function using its mangled name? What happened?
Re: Win32::API accessing DLL
by bulk88 (Priest) on Sep 08, 2012 at 00:24 UTC
    Use the decorated name. MS DLLs are special since they were all made with DEF files where the names are plain and undecorated. @4 means your function takes one 32 bit parameter and is stdcall. cdecls dont have a @12345.
Re: Win32::API accessing DLL
by nikosv (Chaplain) on Sep 08, 2012 at 13:12 UTC
    use dependency walker to load your dll and examine it. Also check "How do I view the parameter and return types of a function?" in the faq
Re: Win32::API accessing DLL
by Anonymous Monk on Sep 07, 2012 at 21:02 UTC
    Be very careful that upper/lower case matches exactly...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://992280]
Approved by marto
Front-paged by tye
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (15)
As of 2015-11-30 20:20 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (781 votes), past polls