Re: [Pharo-users] uFFI ExternalAddress challenges
We are interested in it :) If I recall well Pablo got one version somewhere.
Me too :-) Unfortunately, I only have time for 'weekend' projects, and any help is appreciated :-) Regarding the uFFI calls, is it possible to pass Win32WideString in a similar fashion as a String - or where to look to implement that? Best wishes, Tomaz
On Thu, 12 Sep 2019 at 18:08, Torsten Bergmann <astares@gmx.de> wrote:
From your snippets it looks like you want to do COM Automation on Windows.
Maybe you should have a look at: https://github.com/tesonep/pharo-com
Does that by chance include an implementation of "MS-CFB" Microsoft Compound File Binary https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cfb/50708a61... I was wanting to write a utility to parse headers of MSG files saved from Outlook, to process a for a project email archive by bulk renaming each MSG file with its transmit-date & subject. cheers -ben
Maybe you should have a look at: https://github.com/tesonep/pharo-com
Thanks for the link, I'll check it out - that's probably the work Steph has mentioned. Best wishes, Tomaz
OK, I'm proceeding with the library that I mentioned (http://disphelper.sourceforge.net/) and I got nice results. Pablo's package goes directly into the core of OLE/COM automation and it would be too hard to for me to study it and continue with it at this stage. An example below loads Word for Windows, makes it visible, creates a new document and writes some text: | w | COMEngineAlpha initializeCOM . w := COMEngineAlpha createObjectByName: 'Word.Application'. COMEngineAlpha callObject: w setProperty: '.Visible = %b' withInteger: 1. COMEngineAlpha callObject: w method: '.Documents.Add'. COMEngineAlpha callObject: w method: '.Selection.TypeText(%S)' withString: 'This is a message to appear in Word document.'. COMEngineAlpha safeReleaseObject: w. COMEngineAlpha uninitializeCOM. However, I'd like to marshall a WideString through uFFI so that I won't loose UTF-8 support, of course the plain (String aString) signature doesn't work ("Cannot coerce arguments"). Is there anything I can do myself (i.e. without poking into Pharo virtual machine complexity) to solve this challenge? Best wishes, Tomaz ------ Original Message ------ From: "Torsten Bergmann" <astares@gmx.de> To: tomaz.turk@ef.uni-lj.si; pharo-users@lists.pharo.org Cc: "Any question about pharo is welcome" <pharo-users@lists.pharo.org> Sent: 12. 09. 2019 12:07:34 Subject: Aw: Re: [Pharo-users] uFFI ExternalAddress challenges
From your snippets it looks like you want to do COM Automation on Windows.
Maybe you should have a look at: https://github.com/tesonep/pharo-com
Bye T.
Gesendet: Donnerstag, 12. September 2019 um 11:08 Uhr Von: "Tomaž Turk" <tomaz.turk@ef.uni-lj.si> An: "Any question about pharo is welcome" <pharo-users@lists.pharo.org> Betreff: Re: [Pharo-users] uFFI ExternalAddress challenges
We are interested in it :) If I recall well Pablo got one version somewhere.
Me too :-) Unfortunately, I only have time for 'weekend' projects, and any help is appreciated :-)
Regarding the uFFI calls, is it possible to pass Win32WideString in a similar fashion as a String - or where to look to implement that?
Best wishes, Tomaz
A rudimentary disphelper library "approach" is working OK, I succeeded to create a connection to SQL Server through ADODB, too, which is rather cool, since I've been looking for this functionality for too long. I re-checked Pablo's pharo-com package and it is rather comprehensive - it successfully creates COM servers and more. However, when trying to invoke writing to COM server properties, as in: wordObj propertyNamed: 'Visible' put: true. the call fails with: Primitive failed: primitive #integerAt:size:signed: in ExternalAddress Problematic method uses a primitive <primitive: 'primitiveFFIIntegerAt' module:'SqueakFFIPrims'> which probably doesn't exist. Does anybody know about the purpose/intent and the history of this primitive in 'SqueakFFIPrims'? I think it would be a pitty that we leave Pablo's work unfinished. -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
It seems that there's nothing wrong with the primitive, but with Win32Variant creation in ExternalStructure class>>fromHandle:, specifically with basicNew and Win32Variant class as receiver. In what circumstances the debugger/inspector shows 'error printing' message (on the result of basicNew)? Sorry for newbie questions :-) Best wishes, Tomaz -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
Hi Tomaz, Have you checked Win32WideString in Pharo7/8 and its users? You can do aWindowsWideString := âa wide stringâ asWin32WideString. And then check the senders of Win32WideString, you will find you can declare ffi signatures like this removeEnvironmentVariable: nameString ^ self ffiCall: #( int SetEnvironmentVariableW ( Win32WideString nameString, 0 ) ) Isnât this working for you? If not, Iâd like to have more details on why it does not work, so we can figure out a solution :) Cheers, Guille
El 13 sept 2019, a las 15:22, Tomaž Turk <tomaz.turk@ef.uni-lj.si> escribió:
OK, I'm proceeding with the library that I mentioned (http://disphelper.sourceforge.net/ <http://disphelper.sourceforge.net/>) and I got nice results. Pablo's package goes directly into the core of OLE/COM automation and it would be too hard to for me to study it and continue with it at this stage.
An example below loads Word for Windows, makes it visible, creates a new document and writes some text:
| w | COMEngineAlpha initializeCOM . w := COMEngineAlpha createObjectByName: 'Word.Application'. COMEngineAlpha callObject: w setProperty: '.Visible = %b' withInteger: 1. COMEngineAlpha callObject: w method: '.Documents.Add'. COMEngineAlpha callObject: w method: '.Selection.TypeText(%S)' withString: 'This is a message to appear in Word document.'. COMEngineAlpha safeReleaseObject: w. COMEngineAlpha uninitializeCOM.
However, I'd like to marshall a WideString through uFFI so that I won't loose UTF-8 support, of course the plain (String aString) signature doesn't work ("Cannot coerce arguments"). Is there anything I can do myself (i.e. without poking into Pharo virtual machine complexity) to solve this challenge?
Best wishes, Tomaz
------ Original Message ------ From: "Torsten Bergmann" <astares@gmx.de <mailto:astares@gmx.de>> To: tomaz.turk@ef.uni-lj.si <mailto:tomaz.turk@ef.uni-lj.si>; pharo-users@lists.pharo.org <mailto:pharo-users@lists.pharo.org> Cc: "Any question about pharo is welcome" <pharo-users@lists.pharo.org <mailto:pharo-users@lists.pharo.org>> Sent: 12. 09. 2019 12:07:34 Subject: Aw: Re: [Pharo-users] uFFI ExternalAddress challenges
From your snippets it looks like you want to do COM Automation on Windows.
Maybe you should have a look at: https://github.com/tesonep/pharo-com <https://github.com/tesonep/pharo-com>
Bye T.
Gesendet: Donnerstag, 12. September 2019 um 11:08 Uhr Von: "Tomaž Turk" <tomaz.turk@ef.uni-lj.si <mailto:tomaz.turk@ef.uni-lj.si>> An: "Any question about pharo is welcome" <pharo-users@lists.pharo.org <mailto:pharo-users@lists.pharo.org>> Betreff: Re: [Pharo-users] uFFI ExternalAddress challenges
We are interested in it <emoticon_smiley.png> If I recall well Pablo got one version somewhere.
Me too <emoticon_smiley.png> Unfortunately, I only have time for 'weekend' projects, and any help is appreciated <emoticon_smiley.png>
Regarding the uFFI calls, is it possible to pass Win32WideString in a similar fashion as a String - or where to look to implement that?
Best wishes, Tomaz
participants (5)
-
Ben Coman -
eftomi -
Guillermo Polito -
Tomaž Turk -
Torsten Bergmann