Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Windows programming

Posted on 2002-06-04
6
Medium Priority
?
205 Views
Last Modified: 2010-04-04
hi! i have 2 programs.  program A and program B.  i want program A to communicate with program B through windows messaging wherein program B will then do something on program A's command.  thanks in advance to everyone! :)
0
Comment
[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
  • 3
  • 2
6 Comments
 
LVL 12

Accepted Solution

by:
Lee_Nover earned 300 total points
ID: 7053446
:)

if these programs will run on the same machine then you can use SendMessage
otherwise take a look into mailslots, pipes and sockets

for SendMessage you can simply do:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
    procedure SomeHandler(var Msg: TMessage); message WM_APP + 123;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.SomeHandler(var Msg: TMessage);
begin
     case Msg.WParam of
       0: Msg.Result:=0; // ofcourse you replace this by your handler
       1: Msg.Result:=1;
     end;

     Caption:=Format('%d -> %d', [Msg.WParam, Msg.Result]);
end;

procedure TForm1.Button1Click(Sender: TObject);
var hWin: HWND;
begin
     hWin:=FindWindow('TForm2', 'Form2');
     if hWin > 0 then
        SendMessage(hWin, WM_APP + 123, 1, 0);
end;

procedure TForm1.Button2Click(Sender: TObject);
var hWin: HWND;
begin
     // finc the receiver window - the other app
     hWin:=FindWindow('TForm2', 'Form2');
     if hWin > 0 then
        SendMessage(hWin, WM_APP + 123, 0, 1);
end;

end.


you can do the same for the other app .. just change the handler

that's the basics of messaging
0
 
LVL 46

Expert Comment

by:aikimark
ID: 7053743
don't forget Windows Atoms, too.
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7054552
then we could also go into Memory Mapped files and SendMessage with WM_COPYDATA :)
lots of ways to communicate in windows .. gotta love 'em :)
0
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.

 
LVL 46

Expert Comment

by:aikimark
ID: 7055025
You can probably accomplish this through some CORBA or COM handshaking as well.  

Directory monitoring API. (indirect Sendmessage)
DDE (an oldie)
inter-process Winsock

Dang, this list could get long.

I don't want to confuse dabestprogrammerindauniverse, so let me recommend that Lee_Nover get the points for the correct answer.
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7055054
hey tnx ! :)
0
 
LVL 1

Expert Comment

by:bnemmers
ID: 7055454
I have a component at Torry's that does what you need
look for IPC. It's freeware but beware that this will not work in a NT service app.

http://www.torry.net/vcl/system/appscommunications/bmipc.zip

Good Luck Bill :-)
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

618 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