[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Sending text to program.

Posted on 2003-11-11
7
Medium Priority
?
308 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
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!

 
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 500 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

872 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