jlvill
asked on
Delphi - How send a structure to an other probramm by using SendMessage function
HI everybody,
I'm tryind to send a structure from Program "A" to program "B" by using sendmessage function.
My structure is defined into a (Program "A" and Program "B") common library like this
==>
TIdentifier record of
ID : String;
SID : String;
end;
Into program "A" I'm fulling my structure as below
==>
Program "A"
var
Identifier: TIdentifier;
begin
Identifier.PID := 'PID';
Identifier.SID := 'SID';
sendmessage(ProgramBHandle ,1101,0,in teger(@Ide ntifier));
end;
I'm receiving the message into program "A" like below
==>
procedure Tform1.WndProc(var Msg : TMessage);
var
PID:string;
MsgParm: integer;
Identifier: TIdentifier;
begin
if msg.Msg = 1101 then begin
messagebeep(0);
id := Pointer(msg.lParam);
Identifier(id).
PID:=id^.PID;
showmessage(PID);
PID:=id.PID;
showmessage(PID);
end;
inherited;
end;
But my problem is... can't read my structure. I'm receiving the structure address but I can't
do anything.
I'm tryind to send a structure from Program "A" to program "B" by using sendmessage function.
My structure is defined into a (Program "A" and Program "B") common library like this
==>
TIdentifier record of
ID : String;
SID : String;
end;
Into program "A" I'm fulling my structure as below
==>
Program "A"
var
Identifier: TIdentifier;
begin
Identifier.PID := 'PID';
Identifier.SID := 'SID';
sendmessage(ProgramBHandle
end;
I'm receiving the message into program "A" like below
==>
procedure Tform1.WndProc(var Msg : TMessage);
var
PID:string;
MsgParm: integer;
Identifier: TIdentifier;
begin
if msg.Msg = 1101 then begin
messagebeep(0);
id := Pointer(msg.lParam);
Identifier(id).
PID:=id^.PID;
showmessage(PID);
PID:=id.PID;
showmessage(PID);
end;
inherited;
end;
But my problem is... can't read my structure. I'm receiving the structure address but I can't
do anything.
TIdentifier record of
ID : String;
Identifier.PID := 'PID';
====================
How can this work?
ID : String;
Identifier.PID := 'PID';
====================
How can this work?
philipjc is probably on the correct path. You need to pass your object, not a pointer to your object.
Possible solution paths:
* memory mapped files (philipjc)
* named pipes (philipjc)
* atoms
* TCP (you can stream objects)
* UDP one-way messages (you need to establish msg structure)
* MSMQ for guraranteed delivery
* You can use the file system to transmit data (requires programs to hook the Windows Shell for changes notification or timer-based monitoring)
Possible solution paths:
* memory mapped files (philipjc)
* named pipes (philipjc)
* atoms
* TCP (you can stream objects)
* UDP one-way messages (you need to establish msg structure)
* MSMQ for guraranteed delivery
* You can use the file system to transmit data (requires programs to hook the Windows Shell for changes notification or timer-based monitoring)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great!!!
Thanks esoftbg
Thanks Geo P.S I corrected FindWIndow(nil, PChar(WindowName)) by FindWIndow(PChar(WindowNam e),nil)
It's working!
philipjc and aikimark you're right, the program not run in the same address space.
Thanks all of you ;-)
Thanks esoftbg
Thanks Geo P.S I corrected FindWIndow(nil, PChar(WindowName)) by FindWIndow(PChar(WindowNam
It's working!
philipjc and aikimark you're right, the program not run in the same address space.
Thanks all of you ;-)
To do what you want you should use memory mapped files or use some sort of interprocess communication like pipes etc.