Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sending strings between delphi apps - presumably API SendMessage?

244 views
Skip to first unread message

steve

unread,
Sep 20, 1999, 3:00:00 AM9/20/99
to
Im a complete novice with API - yeh I bet it shows already! anyway I have read
lots of messages about API messaging but still dont know if its the best
"method" for me to use.

I would like to write two apps, when I click a button on one of the apps it
would send a string <255 chrs to the other app to be stored in a variable.

Would sendmessage be the best way to do this? if so, could someone post a small
piece of working code for sender and receiver apps ( I seem to only be able to
work by example - dunno why - just thick I guess) or recomend another way again
with send & receive app.

Mucho TIA!

Steve

Maynard Philbrook

unread,
Sep 21, 1999, 3:00:00 AM9/21/99
to rab...@yahoo.com
You can do it as long as you follow these rules.
#1 obtain the window handle of the app that will receive the message ( you will
need this);
#2.create a global page of memory for all to access (API GlobalAllocate)
#3 place your date in this memory..
#4.PostMessage(OtherAppHandle, Usermessage, GloableMemoryHandle);
-
receiving app will responed to the useMesage.
take the handle and use GlobalUnlock to get the actual pointer to the memory..
extract the data to a local variable, free the Global memory.

Keith Chew SL

unread,
Sep 21, 1999, 3:00:00 AM9/21/99
to

can i ask the reason for developing the 2 apps? why not have one app all
together? most communications protocols r used when apps r developed by
different people. on the contrary, it is also used in client/server apps, in
which you might want to consider COM/ActiveX approaches.

tell us more about the app u r trying to develop. there might be other ways
to accomplish ur task...

regards
Keith


steve <rab...@yahoo.com> wrote in message
news:37e8a7cc...@news.f9.net.uk...

steve

unread,
Sep 23, 1999, 3:00:00 AM9/23/99
to
Okay, just to confuse things more - there may have to be three apps - the string
I need is sent from an antiquated peice of software from many moons ago (cant be
rewritten) , the string is passed as a parameter on a exe file. Okay so I could
use the program that im writing and grab it as a paramstr, BUT, my software
needs to be loaded all the time and cant just be reloaded each time with the
parameter.

So my idea was....

oldprog.exe executes newprog.exe with the parameter, newprog.exe sends the
string via send message to myactual prog. Because I dont have access to the
original source of the old program, there is not much I can do about the way it
works.

And any ideas would be appeciated highly - again, source would be nice!

TIA


On Tue, 21 Sep 1999 12:22:57 +1200, "Keith Chew SL" <keit...@ihug.co.nz> wrote:

:
:can i ask the reason for developing the 2 apps? why not have one app all

:


Maynard Philbrook

unread,
Sep 24, 1999, 3:00:00 AM9/24/99
to rab...@yahoo.com
to send a string vis messages you can do this...
create a global Memory block using
GlobalAllocate, select the flags to allow this memory to be shared and moved ect...

use the GlobalLock the obtain the pointer and store your string in it.
then GlobalUnlock , it is important that you do not keep the handle Locked.
send a Usermessage with the global handle as the parmeter..
the receiving app will take this parameter and use globalLock to obtain the
pointer, remove/read the
data and then GlobalFree the handle to release it fom memory.
Look in your Win32.hlp for these memory functions.

Keith Chew SL

unread,
Sep 24, 1999, 3:00:00 AM9/24/99
to
yup, ur method sounds fine. u might want to make the newprog.exe (app 2) an
invisible one, so that it will not flash each time a message is sent.

as for trasnferring messages, there are many ways to do it, e.g

- file transfer - create/read file (easiest)
- shared memory (relatively easy)
- DDE (old technology)
- active X (new but need some work)

using file transfer approach, you can append the string to a file. this will
allow myactual.exr (app 3) is to read the file without having to worry about
timing issues. however, you will need to perform file locking, so that
multiple app 2 can append to the file as well as allowing app 3 to read it
simultaneously. i think this method will be quite elegant.

regards
Keith

steve <rab...@yahoo.com> wrote in message

news:37eb7c2b...@news.f9.net.uk...

Peter Ingham

unread,
Sep 26, 1999, 3:00:00 AM9/26/99
to
"Keith Chew SL" <keit...@ihug.co.nz> wrote:

>yup, ur method sounds fine. u might want to make the newprog.exe (app 2) an
>invisible one, so that it will not flash each time a message is sent.
>
>as for trasnferring messages, there are many ways to do it, e.g
>
>- file transfer - create/read file (easiest)

Especially if the file is a pipe

--

Peter S Ingham pi...@actrix.gen.nz
Lower Hutt, New Zealand

steve

unread,
Sep 27, 1999, 3:00:00 AM9/27/99
to
Thanks for all your help - fingeres crossed!

Steve

0 new messages