unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button2: TButton;
    Edit1: TEdit;
    ListBox1: TListBox;
    procedure FormDestroy(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

const
n=200;

var
  Form1: TForm1;
  hMappedFile: THandle;
  p: ^char;
  mas: array [1..n] of char;
  er: boolean;
  hReceiver: HWND;

implementation

{$R *.dfm}

procedure TForm1.FormDestroy(Sender: TObject);
begin
UnMapViewOfFile(p);
CloseHandle(hMappedFile);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
i: integer;
begin
er:=false;

hMappedFile:=CreateFileMapping($FFFFFFFF, nil, PAGE_READWRITE, 0, SizeOf(integer)*n, 'Saneea');

if hMappedFile<>0 then
  begin
  p:=MapViewOfFile(hMappedFile, FILE_MAP_WRITE, 0, 0, 0);
  if p=nil then
    er:=true;
  end
else
  er:=true;

if er then
  ShowMessage('Произошла ошибка')
else
  begin
  p^:=chr(length(Edit1.Text));
  inc(p);
  for i:=1 to length(Edit1.Text) do
    begin
    p^:=Edit1.text[i];
    inc(p);
    end;
  hReceiver:=FindWindow(nil, 'RECEIVER');
  SendMessage(hReceiver, WM_USER, 0, 0);
  ListBox1.Items.Add(Edit1.Text);
  end;
end;

end.
