I finally got some time to check Pablo’s PharoCOM package closely. At first
I had problems with simple things, like making Word visible with
properyNamed:put: (it’s frustrating when you see the app on the processes
list but you cannot control it :-)) but then I found the reason – it was a
tiny detail in Win32VariantBool>>#write:to:, and then – voila!

Here’s an example of opening Word for Windows, adding a blank document,
typing some text and getting this text back to Pharo:

Ole32Lib uniqueInstance initLibrary.
wrd := COMDispatchInstance createInstanceByName: ‘Word.Application’.
wrd propertyNamed: ‘Visible’ put: true.

docs := wrd propertyNamed: ‘Documents’.
docs dispatch: ‘Add’.

sel := wrd propertyNamed: ‘Selection’.
sel dispatch: ‘TypeText’ withArguments: {‘Hello from Pharo!’}.

sel dispatch: ‘WholeStory’ .
Transcript show: (sel propertyNamed: ‘Text’); cr.

Another example is with Active Data Objects to get DB access:

conn := COMDispatchInstance createInstanceByName: ‘ADODB.Connection’ .
conn dispatch: ‘Open’ withArguments: { ‘DSN=this; Uid=that; Pwd=theOther;’ }
conn propertyNamed: ‘State’ . –> true!
rst := (COMDispatchInstance createInstanceByName: ‘ADODB.Recordset’) .
rst dispatch: ‘Open’ withArguments: { ‘SomeTableName’ . conn . 3 . 1 }.

The last line raises an exception because not all of the data types that
functions are reporting are implemented yet, as Pablo mentioned in his post.

The package is really nicely prepared. The most impressive is it’s
reflective capability. My “proof of concept” work with DispHelper library
that I mentioned in another forum topic was successful (I can get to the SQL
Server :-)), however it’s a dead-end regarding the reflection.

I’m very interested in COM implementation since I found Pharo to be very
useful as a tool, and since I work in “windowed” environment the COM
interaction is crucial to me. I decided to spent my free evenings working on
the project finalization. I’m not sure of how long will it take though 🙂
Pablo, I hope that I can count on your help regarding the questions about
the overall architecture that you set.

Is anybody else interested in this? Maybe we can join our efforts.

Best wishes,

%d bloggers like this: