Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Perl program calling external .dll functions

by manojghosh (Novice)
on Mar 17, 2011 at 11:41 UTC ( #893734=perlquestion: print w/replies, xml ) Need Help??
manojghosh has asked for the wisdom of the Perl Monks concerning the following question:

Please suggest diffrent methods or ideas in implementing the .dll function call from a perl program in windows. i have tried Win32::API but failed to do so. If perlXS package can help me out? or there is any other method? like i am calling
use Win32::API; my $temp='123456789'; $sp=' '; my $fun=new Win32::API('DataGenerate.dll','GetACC','LL','L' ) or die $ +^E; my $y = $fun->Call($temp,$sp); print($y);
whereas our GetACC() is defined like this: Long GetACC(String,String); The interpreter crashes as i am running this ...!

Replies are listed 'Best First'.
Re: Perl program calling external .dll functions
by marto (Bishop) on Mar 17, 2011 at 11:46 UTC
Re: Perl program calling external .dll functions
by Jenda (Abbot) on Mar 17, 2011 at 15:09 UTC

    Waitasecond ... what language is the DLL implemented in? C#? If it's a .Net DLL you can't call it using Win32::API. ActiveState's PerlNET would work, not sure what other options you have.

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

Re: Perl program calling external .dll functions
by ikegami (Pope) on Mar 17, 2011 at 17:35 UTC

    I don't know what «String» is — it's not a standard C type or a WinAPI type — but it's definitely not the same as «uint32_t» ("L").

    I don't know what «Long» is — it's not a standard C type or a WinAPI type either — but it's not necessarily the same as «uint32_t» ("L").

    Could you provide more information about those types? Also, could you find out what calling convention is used? Win32::API assumes __stdcall unless you tell it it's __cdecl.

      simply the the .dll function is written in C++ and 2 string type arguments are passed through it. and it has a long return type. actually this .dll behaves fine with calling from VB6.0 but trying with perl, interpreter crashes in its call or return 0 on passing argument type mentioned as 'P'(Pointer to string).

        Assuming the STL even defines the internal storage format of a String, I don't know what it is. Whatever it is, it's definitely not a uint32_t as you're telling Win32::API it is.

        "P" passes a pointer to the a copy of the scalar's string buffer. Don't know if your String is compatible with what you are passing were you to use "P". But you're not using "P". You're using "L".

        You've provided no useful data about the type. You didn't provide the calling convention used.

        I think you'd be much better off using Inline::CPP.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://893734]
Approved by marto
help
Chatterbox?
[stevieb]: perldigious: video near our hq in Montreal. Here in Calgary, it's -28c... we've only got 3" of snow so far, but there are several feet in the mountains already
[perldigious]: Snowshoeing time stevieb? I need to buy a pair so I can walk my German Shepherd properly through the country.
[stevieb]: yeah, I snowshoe a fair amount in the mountains. I also use spikes similar to these very often as well
[perldigious]: Discipulus: alternate link
[stevieb]: LOL you can easily replace "Helsinki" with "Alberta"
[perldigious]: I used to live at the top of a very steep hill stevieb, I can relate to the video. Literally used to have to build up momentum and try to force my vehicle to make it up the hill to park in my driveway properly... didn't always make it.

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (10)
As of 2016-12-06 16:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (112 votes). Check out past polls.