; Author: Carlo Somigliana (for PB4.40) ; email: somic@libero.it, site: http://semelinanno.com ; Date: 6. Dicember 2010 ; OS: Windows ; ----------------------------------------------------------------------------- ; Public domain ; ----------------------------------------------------------------------------- ; Inter Process SendMessage ; ----------------------------------------------------------------------------- ; InterProcessMssg ;-------------------------- ; This code has been inspired by an article on CodeProject site (Reference: CProcessData ; A template class To ease up SendMessage calls across processes: By Nishant Sivakumar ; link: http://www.codeproject.com/KB/winsdk/CProcessData.aspx) ; I started trying to translate the C++ Class in PB for the PB comunity to solve an old problem (for me) ; of the Send/PostMessage functions not working across different processes (not always, only when the ; result is not in the returned parameter but is a buffer/structure). ; ; In fact, in the usual way the destination buffer can not be mapped in the other process address ; space and the message function fails. With this functions (IPM_...) you should be able to overcome this ; limit (if by design, it is not very well documented) and access with the functions VirtualAllocEx_ ; And Read/WriteProcessMemory_ the required data ; ; Soon the exercise expanded (or exploded) to become more general and requiring additional coding and ; testing of various solutions. ; ; This code has 2 sections: a DLL part and a Test (CompilerIf) part ; Run it should show the results of various examples, while compiled it should give a DLL with the ; IPM and some other usefull functions (without the test code). ; The DLL is not working (see 3rd WARINIG below). ; ; The _DllTest_ assemble the code written to test various solutions. Take it as is: it is badly written ; and poorly commented, but I hope understandable (with some efforts) ; It looks for a specific rathet window using different combinations of parameters for SenMessage; ; If Not found it runs the relevant program and then search again for the window ; ; IMPORTANT: 3 WARNINGS: ; 1. It was born as a DLL but the code has not been written to be a real DLL (not yet) ; 2. Example 7 (with WINWORD) is not working and I've decided to stop spending to much time with MS products ; 3. Procedure FindWindowBy there is a CompilerIf directive to avoid a *Memory causes a "Invalid Memory Access" ; after approx. 160 callbacks of EnumChildWindows_ ; I don't have the same problem with Asci Executable or using a string as buffer. ; I leave to the many programmers more expert than me the job to identify the bug in this code ; or in PB IDE). Just a small request: let me know if you discover something. ; ; VERY IMPORTANT: ; The entire code takes benefit from the free contribution of other PB experts (much more than me) ; and is then released FREE for the PB community. Do what you want with it (at your own risk...;-) ; If you want to drop me a message for feedback (any comments and bugs), feel free to do it ; ; Well, this has been my 2009 Christmas fun (???) and my modest gift to the forum. ; ; Happy 2010 To each PB programmer. ; ; Regards, ; Somic