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

Re: Exposing perl code as a COM object

by JamesNC (Chaplain)
on Dec 12, 2005 at 15:03 UTC ( #516027=note: print w/replies, xml ) Need Help??

in reply to Exposing perl code as a COM object

I second holli suggestion. I have used the Windows Script Component-WSC for lots of stuff and it works GREAT and you can even make it a Distributed COM object ( info in MicroSofts WSC docs ). Here is one serious pitfall that will save you some head scratching. The WSC file you create is installed most easily by right clicking the file and then selecting Register. You will also see an option "Generate Type Library". Don't waste your time. The Type Library it creates will throw a exception at runtime if you add it as a reference (in Excel or Word) because the object type defined in the Type Library does not and never could match the object you define in your WSC. MicroSoft acknowledges the problem, but doesn't change the docs or fix the problem...<sigh>. ActiveState's PerlCtrl DOES correctly generate the typelib, so if you need the typelib then purchase the PerlDevKit ( it is a great deal IMO and has lots of great stuff like perlapp and perltray and PerlNET ).

After you read the docs and try the examples, you may wonder how to share a perl hash or array with the MicroSoft world. The key is to use Win32::OLE::Variant and Win32::OLE to create either a VT_ARRAY|VT_VARIANT (use the Put method to store ) or use OLE and CreateObject("Scripting.Dictionary") if you want to use a hash-like object ( and yes, you can save other objects as keys or values) "Scripting.Dictionary" was modeled after Perl hashes I believe.:-)
I have some examples if you need more help. I am too busy right now to post them right now.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2016-10-24 04:17 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (302 votes). Check out past polls.