Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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
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 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: http://unixwiz.net/techtips/win32-callconv.html#conv

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...
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 (Hermit) 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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2014-09-21 06:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (167 votes), past polls