Solved

Sending text to program.

Posted on 2003-11-11
7
302 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Show Listview image from database (String field) 5 150
DBGrid or StringGrid ? 6 120
DBCtrlGrid, Delphi, Scroll 7 33
Typecasting TBytes to Integer in Delphi XE8 2 37
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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