Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Accessing dll with Perl?

by Anonymous Monk
on Oct 07, 2008 at 14:58 UTC ( [id://715805]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I've created a dll using ActiveStates PerlCtrl and need to access the perl routines inside. Is there an easy way to do this? All of the documentation references VB to access them.

Thanks

Replies are listed 'Best First'.
Re: Accessing dll with Perl?
by jplindstrom (Monsignor) on Oct 07, 2008 at 15:39 UTC
    Not sure it'll work, but see if Win32::OLE can do that.

    Can you show some example VB code to do this? Maybe we'll recognize something.

    /J

      Here is the perl code for that's inside the generated dll
      package Hello; sub Hello { return "Hello, World"; } =pod =begin PerlCtrl %TypeLib = ( PackageName => 'Hello', # DO NOT edit the next 3 lines. TypeLibGUID => '{E91B25C6-2B15-11D2-B466-0800365DA902}', ControlGUID => '{E91B25C7-2B15-11D2-B466-0800365DA902}', DispInterfaceIID=> '{E91B25C8-2B15-11D2-B466-0800365DA902}', ControlName => 'HelloWorldControl', ControlVer => 1, ProgID => 'Hello.World', DefaultMethod => '', Methods => { 'Hello' => { RetType => VT_BSTR, TotalParams => 0, NumOptionalParams => 0, ParamList =>[ ] }, }, # end of 'Methods' Properties => { } , # end of 'Properties' ); # end of %TypeLib =end PerlCtrl =cut
      and here is the VB code that would access it:
      Dim objHello Set objHello = CreateObject("Hello.World") MsgBox objHello.Hello
      Seems fairly simple but I'm having a brain cramp or something :)
Re: Accessing dll with Perl?
by Anonymous Monk on Oct 07, 2008 at 17:32 UTC
    I figured it out and posted the code below if anyone needs it.
    use Win32; use Win32::OLE; my $objHello; $objHello = Win32::OLE->new('Hello.World'); print $objHello->Hello;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-25 03:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found