[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Sending text to program.

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

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

649 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