Solved

Sending text to program.

Posted on 2003-11-11
7
296 Views
Last Modified: 2010-04-05
Hey.

I use this line to send a char to a program.

PostMessage(hApp, WM_USER + 1678, Ord(AryChar[0]), 0);

Any idea how you send text to a program, since I can only use integers with this.

Thanks.
0
Comment
Question by:JuiciJJ
7 Comments
 
LVL 6

Expert Comment

by:GloomyFriar
ID: 9724558
To interprocess communications you can use:
1. Memory mapped files
2. Pipes
3. TCP/IP, UDP
4. Dll with shared segment
0
 
LVL 6

Expert Comment

by:DaFox
ID: 9724567
Hi,

PostMessage(..., Integer(PChar(str)), 0);

Markus
0
 
LVL 12

Expert Comment

by:andrewjb
ID: 9724575
.... send lots of chars, one after another?

You can't directly send a string, since the memory for that string would be in the wrong application. The message passing mechanism only has space for a couple of integers or pointers, so you just can't. Alternative is to use some other inter-process mechanism like pipes, or shared memory, or RPC or COM or something.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 12

Expert Comment

by:andrewjb
ID: 9724580
DaFox - don't think that'll work.
0
 
LVL 6

Expert Comment

by:DaFox
ID: 9724632
You're right - passing pointers does only work inside your own process. Silly me... Sorry!!
0
 
LVL 8

Accepted Solution

by:
gmayo earned 125 total points
ID: 9724635
One way is to use a hidden edit box on the other app and use that to send the text. You can even "press" a button to indicate to the other app that the text is there!

procedure SetWindowTextEx(win : HWND; text : string);
var
      res : DWORD;
begin
      SendMessageTimeout(win, WM_SETTEXT, 0, Integer(@text[1]), 0, 1000, res);
end;

Get the handle of the edit box (using FindWindow and/or EnumChildWindows) and pass that to the above function along with the text you wish to pass.

Geoff M.
0
 
LVL 3

Expert Comment

by:BJThomsen
ID: 9725181
type

TCopyDataStruct = record
  dwData: LongInt; // User Defined Data Param
  cbData: LongInt; // Length of data pointed to by lpData
  lpData: Pointer;
end;

TRecToPass = packed record
  s: string[255];
end;

procedure SendAString;
var
  Msg: TCopyDataStruct;
  Rec: TRecToPass;
Begin
  Rec.s := 'Hi There I'm a String';


  Msg.dwData := 0; // User Defined
  Msg.cbData :=  sizeof(Rec) // Size of data pointed to
  Msg.lpData := @Rec
  SendMessage (hApp, WM_COPYDATA,  WPARAM (Application.Handle), LPARAM (@Msg));

end;
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now