Receptor ipc:
Code: Select all
unit uIPCReceiver;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, madCodeHook;
type
TAppDataFolder = record
Path : array[0..254] of Char;
end; PAppDataFolder = ^TAppDataFolder;
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure OnNewRec(name: pchar; messageBuf: pointer; messageLen: dword;
answerBuf: pointer; answerLen: dword); stdcall;
var
mfStruct: TAppDataFolder;
waitFor: Boolean;
source: string;
begin
if Name = 'AppDataFolder_' then
begin
with PAppDataFolder( MessageBuf )^ do
begin
// i need set return here
end;
end
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
CreateIpcQueue( 'AppDataFolder_', OnNewRec );
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
DestroyIpcQueue('AppDataFolder_');
end;
end.
Code: Select all
unit uIPCsender;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, madCodeHook, StdCtrls;
type
TAppDataFolder = record
Path : array[0..254] of Char;
end; PAppDataFolder = ^TAppDataFolder;
TForm1 = class(TForm)
btn1: TButton;
edt1: TEdit;
procedure btn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btn1Click(Sender: TObject);
var
mfStruct: TAppDataFolder;
waitFor: Boolean;
source: string;
begin
source := 'test';
FillMemory( @mfStruct, SizeOf(TAppDataFolder), 0 );
CopyMemory(@mfStruct.Path[0], @source[1], Length(source));
if SendIpcMessage('AppDataFolder_', @mfStruct, SizeOf(TAppDataFolder),
@waitFor, SizeOf(Boolean)) then
begin
showmessage(PChar( @mfStruct.Path[0] ));
end
else
showmessage('not');
end;
end.